Reputation: 122
I want to do something like this
int amountOfDimensions = 3;
Array a = new Array(3);
but of course that is not a thing in C#,
but is there's something that do the same thing ?
Upvotes: 0
Views: 41
Reputation: 186668
Try Array.CreateInstance, e.g.
// array of int with 3 dimensions with correspondent lengths 2, 3 and 4:
// i.e. result will be int[2, 3, 4]
var result = Array.CreateInstance(typeof(int), 2, 3, 4);
Upvotes: 4