(ZT) List VS ArrayList 性能比较
C# List
List
List
鉴于这两点 ,可以得出,当数据量小的时候呢,ArrayList的操作时间上要比List
但是在数据量大的时候呢,List
//测试
List
Stopwatch sw = new Stopwatch();
sw.Start();
for (int i = 0; i < 15000000; i++)
{
list.Add(new Person { Id = i, Name = "i" });
}
sw.Stop();
System.Console .WriteLine (sw.Elapsed);
sw.Reset();
ArrayList arraylist = new ArrayList();
sw.Start();
for (int i = 0; i < 15000000; i++)
{
arraylist.Add(new Person { Id = i, Name = "i"});
}
sw.Stop();
System.Console.WriteLine(sw.Elapsed);
0 Comments:
Post a Comment
<< Home