G
Guest
I have a type of System.Type. It indicates an primitive type such as Int32. I
try to use the following code to create an array
Type arrayType = type.MakeArrayType(5);
object objArray = Activator.CreateInstance(arrayType);
but I got the following error:
{"No parameterless constructor defined for this object."}
Apparently, this is caused by the fact that the array type does not have a
default constructor.
How do I create the array using reflection?
try to use the following code to create an array
Type arrayType = type.MakeArrayType(5);
object objArray = Activator.CreateInstance(arrayType);
but I got the following error:
{"No parameterless constructor defined for this object."}
Apparently, this is caused by the fact that the array type does not have a
default constructor.
How do I create the array using reflection?