List<T>有没有溢出的可能?如果有 多长?

解决方案 »

  1.   

    测试List<String> list = new List<string>();            try
                {                for (int i = 0; i < int.MaxValue; i++)
                        list.Add("one");
                }
                catch
                {
                    Console.WriteLine(list.Count);
                }
    Exception of type 'System.OutOfMemoryException' was thrown.
    the count of list is 134217728
      

  2.   

    List(T).capacity
    outofmemoryexception 没有足够内存