int[] a = new int[5];
string[] b = new string[1];
The types of both a
and b
inherit from the abstract System.Array
, but there is no real classes in the built-in library(it seems that there are some runtime types, you can't find the type defination class of an int[]
). Can you tell me what happens while compiling? And why did they(the c# team) make this design(I mean why it's not something like Array<T>
,instead they are using an abstract class with compiler magics)?
I would recommend getting the ECMA 335 spec and looking for Arrays if you want to know the low level detail: http://www.ecma-international.org/publications/standards/Ecma-335.htm
[] is a syntax(syntatic sugar) for defining Arrays in c#. Maybe CreateInstance will be replaced at runtime
is same as
Source for CreateInstance (taken from reflector)