Tip
If the constructor has no more than four parameters, then you can use the generic
CreateInstance overloads for better performance if the types are known at compile time.
public Object CreateInstance(
params Object?[]? parameters
)
Public Function CreateInstance (
ParamArray parameters As Object()
) As Object
public:
Object^ CreateInstance(
... array<Object^>^ parameters
)
member CreateInstance :
parameters : Object[] -> Object
Invoking the constructor for the first time is slower than the System.Reflection.MethodBase.Invoke method but further calls are much faster.
If the constructor has ref/ parameters pass a preallocated array to parameters. The parameters passed by reference will be assigned back to the corresponding array elements.
ArgumentNullException | This CreateInstanceAccessor represents a constructor with parameters and parameters is . |
ArgumentException | The type of one of the parameters is invalid.
-or- parameters has too few elements. |
InvalidOperationException | This CreateInstanceAccessor represents a static constructor, a constructor of an abstract class, or.a constructor of an open generic type. |
NotSupportedException | On .NET Framework the code is executed in a partially trusted domain with insufficient permissions. |