读取txt文件和ArrayList的操作

   string filename = @"E:/testfile.txt";
   string temp;
   string textline;
//   string [] textwords = null;
//   char [] separators = {' ', '/n', ';', ':'};

   ArrayList text = new ArrayList();
   StreamReader freader = File.OpenText(filename);
   while((textline = freader.ReadLine()) != null)
   {
    if( textline.Length == 0)
     continue;
    text.Add(textline);
   }
   Console.WriteLine("inserted {0} lines",text.Count);
   Console.WriteLine("Count {0}, Capacity {1}",text.Count, text.Capacity);
   text.TrimToSize();
   Console.WriteLine("Capacity {0}", text.Capacity);

   temp = Console.ReadLine(); 

你可能感兴趣的:(读取txt文件和ArrayList的操作)