MethodAccessorInvoke(Object, Object) Method
Invokes the method. The return value of void methods is always .
For static methods the instance parameter is omitted (can be ).
Namespace: KGySoft.ReflectionAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public Object? Invoke(
Object? instance,
params Object?[]? parameters
)
Public Function Invoke (
instance As Object,
ParamArray parameters As Object()
) As Object
public:
Object^ Invoke(
Object^ instance,
... array<Object^>^ parameters
)
member Invoke :
instance : Object *
parameters : Object[] -> Object
- instance Object
- The instance that the method belongs to. Can be for static methods.
- parameters Object
- The parameters to be used for invoking the method.
If the method has ref/out parameters the corresponding array elements are assigned back with the results.
ObjectThe return value of the method, or
for
void methods.
Invoking the method for the first time is slower than the System.Reflection.MethodBase.Invoke
method but further calls are much faster.
If the method has ref/ parameters pass a preallocated array to parameters.
The parameters passed by reference will be assigned back to the corresponding array elements.
If the method has no more than four parameters, then you can use the strongly typed
InvokeStaticAction,
InvokeStaticFunction,
InvokeInstanceAction or
InvokeInstanceFunction
methods for better performance if the types are known at compile time.
If the method is a non-readonly instance method of a value type or has ref/ or pointer parameters/return value,
then the .NET Standard 2.0 version of this method defaults to use regular reflection to preserve possible mutations and be able to assign the parameter values back to
the parameters array. To experience the best performance try to target .NET Standard 2.1 or any .NET Framework or .NET Core/.NET platforms instead.