Click or drag to resize

ExtensionsReflectionCreateInstance Method (Type, Object)

Creates an instance of the specified type using the constructor that best matches the specified parameters.

Namespace:  Cauldron
Assembly:  Cauldron.Activator (in Cauldron.Activator.dll) Version: 3.2.0.1 (3.2.0.1)
Syntax
C#
public static Object CreateInstance(
	this Type type,
	params Object[] args
)

Parameters

type
Type: SystemType
The type of object to create.
args
Type: SystemObject
An array of arguments that match in number, order, and type the parameters of the constructor to invoke. If args is an empty array or null, the constructor that takes no parameters (the default constructor) is invoked.

Return Value

Type: Object
A reference to the newly created object.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Type. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentNullExceptiontype is null
TypeIsInterfaceExceptiontype is an interface
See Also