This example shows how to create an object when you only have its Type metadata.
: Scanning the type’s metadata to find a constructor signature matching the provided arguments. activators dotnet 4.6.1
The most common way to create an object is by using the CreateInstance method, which requires a Type object. This example shows how to create an object
Type type = typeof(MyClass); ConstructorInfo ctor = type.GetConstructor(Type.EmptyTypes); object instance = ctor.Invoke(null); Use code with caution. 2. Compiled Expression Trees ConstructorInfo ctor = type.GetConstructor(Type.EmptyTypes)