The Assembly CreateInstance has three overloads, and the first argument needs to be a complete class name for a string representation. The second argument is a bool type, and if true, indicates that the first argument is case-insensitive.
Third: A bit mask that affects how the search is performed. This value is a combination of bit flags in the System.Reflection.BindingFlags.
Binder: An object that enables binding, parameter type coercion, member invocation, and MemberInfo object retrieval through reflection. If binder is null, the default binder is used. An array of type Args:object that contains the arguments to pass to the constructor. This parameter array must match the parameters of the constructor to be invoked in terms of quantity, order, and type. If the default constructor is required, the args must be an empty array or null.
Culture: An instance of the CultureInfo used to control type coercion. If this is null, the CultureInfo of the current thread is used. (for example, this is for converting a String representing 1000 to a
The Double value is required because different cultures represent 1000 in different ways.
Activationattributes: Contains one or more arrays of properties that can participate in activation. is typically an array that contains a single System.Runtime.Remoting.Activation.UrlAttribute object.
System.Runtime.Remoting.Activation.UrlAttribute Specifies the URL required to activate the remote object. For a detailed description of client-activated objects, see client activation.
static method CreateInstance of the Activator class.
The first parameter description for CreateInstance is the name of the Assembly, the current assembly when NULL, and the second parameter that describes the type name to create. Activator.CreateInstance returns a ObjectHandle object that must be unwrap () to return the object type, which can then be coerced into the type we need (in this case, MathClass). ObjectHandle is contained in the System.Runtime.Remoting namespace, and it is remoting related, in fact the ObjectHandle class is simply a wrapper over the original type for marshaling.
Non-parametric constructs:
A parameter construct:
Dynamic invocation:
. Calling methods using InvokeMember
InvokeMember ("Method name", BindingFlags.InvokeMethod, null, object instance, method parameter);
Static: InvokeMember ("Method name", BindingFlags.InvokeMethod, NULL, ' type ', method parameter);
. Methodinfo.invoke Call method
MethodInfo mi = T.getmethod ("Method name", BindingFlags.Instance bindingflags.public);
Mi. Invoke (object instance, null);
Static
MethodInfo mi1 = T.getmethod ("Method name", BindingFlags.Static bindingflags.public);
Mi1.invoke (null, method parameters);
can achieve maximum polymorphism with reflection