遍历时间00:00:02.2544873
//ArrayList arr = new ArrayList();
//Stopwatch watch = new Stopwatch();
//watch.Start();
//for (int i = 0; i < 10000000; i++)
//{
// arr.Add(i);
//}
//watch.Stop();
//Console.WriteLine(watch.Elapsed);
//Console.ReadKey();
//--------------------------------------
////遍历时间00:00:00.2196227 使用泛型集合,减少了装箱于拆箱的工作,减少工作时间
//List<int> arr = new List<int>();
//Stopwatch watch = new Stopwatch();
//watch.Start();
//for (int i = 0; i < 10000000; i++)
//{
// arr.Add(i);
//}
//watch.Stop();
//Console.WriteLine(watch.Elapsed);
//Console.ReadKey();
编程中尽量少用到装箱拆箱,会增加程序的一些性能 |