为什么这段代码会是一个死循环,不能结束呢??
using System;
using System.Collections;
using System.Collections.Generic;
namespace DefaultNamespace
{
public class ListTest
{
static public void Main(String[] args) {
int max = 1000*1000*1;
List<Int32> list = new List<Int32>();
DateTime st = DateTime.Now;
int temp = 0;
for (int i = 0; i < max; i++) {
list.Add(i);
temp = list[0];
temp++;
list.Remove(0);
}
Console.WriteLine(DateTime.Now.Ticks - st.Ticks);
}
}
}
初学 .net 2.0 ,写了以上的代码,居然在我的机器(P4 3.0G + 512M 内存)上,使用 .net 2.0 执行上面编译出来的代码, 居然执行了 5分钟还不结束,
是我的程序有问题??
还是 .net 真的这么慢吗?!!!!!!