There is no concept of "heap" or "stack" when creating objects in C# or .NET. While the list is stored on the heap, that is really an implementation detail of how the CLR manages its memory.
There is no boxing or unboxing going on here. That is the advantage of using the generic List
class over the non-generic ArrayList
. When a new instance of List<int>
is created, it is as if you wrote a class with the sole purpose of managing a list of int
. There is not even any casting going on behind the scenes when an int
is retrieved from the list.