- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
class TReadWrapper<TItemType>
    {
		public static object item(string ItemString)
        {
			if (typeof(TItemType) == typeof(double))
				return Convert.ToDouble(ItemString);
            TDbg.Assert(false);
            return null;
        }
    };
    class TRead<TItemType>
    {
		public static TItemType item(StreamReader BinaryStream)
        {
			string ItemString = BinaryStream.ReadLine();
			if (ItemString == null)
				throw new Exception();
			return (TItemType)TReadWrapper<TItemType>.item(ItemString);
        }
    };
	class TFileToList<TListItem> : List<TListItem>
    {
        public TFileToList(string FileName)
        {
			if(typeof(TListItem)==typeof(char))
			{
				StreamReader file = new StreamReader(FileName, Encoding.Unicode);
				string FileData = file.ReadToEnd();
				foreach (char item in FileData)
					this.Add((TListItem)(object)item);
				file.Close();
				return;
			};
			StreamReader fileSource = new StreamReader(FileName, Encoding.Unicode);
			try
            {
				for (;;)
					this.Add(TRead<TListItem>.item(fileSource));
			}
			catch
			{
			};
			fileSource.Close();
        }
    }
    class TListToFile<TListItem>
    {
        static public void rewrite(string NameOfDestinationFile, List<TListItem> Source)
        {
			if(typeof(TListItem)==typeof(char))
			{
				StreamWriter file = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
				foreach (TListItem item in Source)
					file.Write(item);
				file.Flush();
				file.Close();
				return;
			};
			StreamWriter fileDestination = new StreamWriter(NameOfDestinationFile, false, Encoding.Unicode);
			foreach (TListItem item in Source)
				fileDestination.WriteLine(Convert.ToString(item));
			fileDestination.Flush();
			fileDestination.Close();
        }
    }
                                 
        
сколько можно постить УГ?
че, такой тупой, что не сообразил?
facepalm.cs
if(typeof(TListItem)==typeof(char))
Это не весь код, но думаю принцип понятен
Говнокодерный код "Перегоняет из списка в файл и обратно".
Код вселенской красоты "Добавляет одновременно в список и файл".