Creates an instance of a specified type using the specified constructor. The constructor that is to be invoked must be accessible and provide the most specific match with the specified argument list, under the constraints of the default binder.
[Visual Basic] Overloads Public Shared Function CreateInstance( _ ByVal type As Type, _ ByVal args() As Object _ ) As Object [C#] public static object CreateInstance( Type type, object[] args ); [C++] public: static Object* CreateInstance( Type* type, Object* args[] ); [JScript] public static function CreateInstance( type : Type, args : Object[] ) : Object;
A reference to the newly created object.
Exception Type | Condition |
---|---|
AccessException | The caller does not have sufficient permissions to call this method.
An element of args does not meet the contract of the constructor being invoked. |
TargetInvocationException | The constructor being called throws an exception. |
Activator Class | Activator Members | System Namespace | Activator.CreateInstance Overload List