Hi,@兰树豪. Welcome Microsoft Q&A.
Type Class represents type declarations: class types, interface types, array types, value types, enumeration types, type parameters, generic type definitions, and open or closed constructed generic types.
Type
is the root of the System.Reflection functionality and is the primary way to access metadata. Use the members of Type to get information about a type declaration, about the members of a type (such as the constructors, methods, fields, properties, and events of a class), as well as the module and the assembly in which the class is deployed.
You could see Remarks for more information.
It cannot be directly declared a variable or instantiate an object.
If you use the code typeA typeaa = new typeA();
it will produce an error CS0118 'typeA' is a variable but is used like a type.
As Peter said, you could use Activator.CreateInstance Method .
The CreateInstance<T>() generic method is used by compilers to implement the instantiation of types specified by type parameters.
object typeaa = Activator.CreateInstance(typeA);
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.