System.Reflection.MethodBase.Invoke C# (CSharp) Method

Invoke() public method

Invokes the method or constructor represented by the current instance, using the specified parameters.
The parameter is null and the method is not static.-or- The method is not declared or inherited by the class of . -or-A static constructor is invoked, and is neither null nor an instance of the class that declared the constructor. The elements of the array do not match the signature of the method or constructor reflected by this instance. The invoked method or constructor throws an exception. -or-The current instance is a that contains unverifiable code. See the "Verification" section in Remarks for . The array does not have the correct number of arguments. The caller does not have permission to execute the constructor. The type that declares the method is an open generic type. That is, the property returns true for the declaring type. The current instance is a .
public Invoke ( object obj, object parameters ) : object
obj object The object on which to invoke the method or constructor. If a method is static, this argument is ignored. If a constructor is static, this argument must be null or an instance of the class that defines the constructor.
parameters object An argument list for the invoked method or constructor. This is an array of objects with the same number, order, and type as the parameters of the method or constructor to be invoked. If there are no parameters, should be null.If the method or constructor represented by this instance takes a ref parameter (ByRef in Visual Basic), no special attribute is required for that parameter in order to invoke the method or constructor using this function. Any object in this array that is not explicitly initialized with a value will contain the default value for that object type. For reference-type elements, this value is null. For value-type elements, this value is 0, 0.0, or false, depending on the specific element type.
return object
        public object Invoke(object obj, object[] parameters)
        {
            return this.Invoke(obj, BindingFlags.Default, null, parameters, null);
        }

Same methods

MethodBase::Invoke ( object obj, BindingFlags invokeAttr, Binder binder, object parameters, CultureInfo culture ) : object

Usage Example

        static StackObject *Invoke_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Object[] @parameters = (System.Object[]) typeof(System.Object[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Object @obj = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Reflection.MethodBase instance_of_this_method = (System.Reflection.MethodBase) typeof(System.Reflection.MethodBase).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Invoke(@obj, @parameters);

            object obj_result_of_this_method = result_of_this_method;

            if (obj_result_of_this_method is CrossBindingAdaptorType)
            {
                return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true));
            }
            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true));
        }
All Usage Examples Of System.Reflection.MethodBase::Invoke