In C# one can instantiate an Array with the special square bracket syntax new int[3]. This is different to other types which you instantiate by calling the constructor new List<int>(). Can you use the ordinary syntax to create an Array?
I tried new System.Array<int>(3) but it blows up
The non-generic type ‘System.Array’ cannot be used with type arguments
System.Arrayitself is abstract, so you won’t be able to instantiate it using its constructor. And as evidenced by your error, it’s not actually generic either; it only gets its type through implementing generic collection interfaces at runtime (see also this related answer):For the above reasons, the
System.Arrayclass provides a convenience method calledCreateInstance()which you can use instead:Be very careful when using this method, though, as the resultant
arraywill not be strongly-typed at compile-time! If you want it to be strongly-typed you must cast it after creating it (and no, simply declaringint[] arraywon’t be enough):