Is there a limit on how many object a list can hold?
Only those imposed by your physical architecture, available memory etc...
There's an easy way to find out :-)
int count = 0;
while (true)
{
myList.Add(new object());
Console.WriteLine("added " + count++ + " objects");
}
Please keep in mind that large collections might end up on Large Object Heap. This part of managed memory doesn't get cleaned up as well as Gen0,1,2, so please proceed with caution. Let the runtime select collection sizes based on the data that you actually need to add.
I believe it is limited to the amount of memory you have. The more you add to the List, the more items are added to the stack until the reference is released and the garbage collector grabs it back.
The .Count property of a list is an integer, so it's somewhat limited in this regard.
If you look at the count/item/etc property of the generic List (of T); it is an integer.
So i guess Integer.MaxValue (2147483647) is a good guess.