Are Generic lists stored on the stack Or the heap?
//List of Ints List<int> myInts = new List<int>(); myInts.Add(5); myInts.Add(10); myInts.Add(20);
Is myInts stored on the stack or the heap? If I add an int to the list, does boxing or unboxing occur?
myInts
int
For structs like int, the generic list is getting specialized and therefore no boxing/unboxing is required.
Note that the values themselves are stored in a backing array of the List nevertheless.
List