How do I create a type object that represents the type of an array with a given element type?
Type t = MakeArrayType(elementType); // How?
Such that
Assert(t.GetElementType() == elementType);
I can create a dummy instance of my requested array and then get the type from there. But I wonder if there is a way to get the type without creating the instance first?
object myArrayInstance = Array.CreateInstance(elementType, 0);
Type t = myArrayInstance.GetType(); // This is the desired type.
If
trefers to aType, thent.GetType()will obviously betypeof(Type)or a subtype – nottypeof(Array).However, I suspect you want
Type.MakeArrayType: