This article describes the usage of () method in C#. Share it for your reference. The specific analysis is as follows:
Activator class
Contains specific methods to create object types locally or from remotely, or to obtain references to existing remote objects.
C# dynamically creates class instances in a class factory, using the method:
1. (Type)
2. (Type, Object[])
The only difference between the two methods is: creating a constructor without parameters and creating a constructor with parameters.
//(Type) object result = null; Type typeofControl =null; typeofControl = (vFullClassName); result = (typeofControl);
//(Type,Object[]) object result = null; Type typeofControl =null; typeofControl = (vFullClassName); result = (typeofControl, objParam);
However, when creating dynamically, instances of classes in DLLs of external applications may be used dynamically. At this time, decompile operations are required and the Assembly class under the control is named using Reflection.
//First use the Assembly class to load the DLL, and then obtain the class based on the full path of the class object result = null; Type typeofControl = null; Assembly tempAssembly; tempAssembly = (vDllName); typeofControl = (vFullClassName); result = (typeofControl, objParam);
I hope this article will be helpful to everyone's C# programming.