I was thinking about this. classes are obviously passed around by ptr. I suspect structs are passed around by copying it but i don’t know for sure. (it seems like a waste for an int array to have every element a ptr. and passing ptrs for ints)
But thinking about it, List<MyStruct> can not know the size of my struct. What happens when i do this? Are there multiple copies of “List`1” and every time i use it with a storage size it does not have it creates a new implementation? (adjusting for the new offsets of T and such).
That could make sense since the source would be in the CIL inside of a DLL. But i am completely guessing, how is it done? Perhaps a reference or page # to the ECMA standards?
Generics use the concept of open and closed generic types: A parametrized generic class definition (i.e.
List<T>) is an open generic type of which the runtime generates a closed generic type for each different use you have in your code, i.e. a different type is created forList<int>and forList<MyStruct>– for each closed generic type the size and type ofTis known at run-time.Clarification from MSDN: