ReflectorInvokeMethod(Object, MethodInfo, Type, ReflectionWays, Object) Method

Invokes a method represented by the specified MethodInfo.

Definition

Namespace: KGySoft.Reflection
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public static Object? InvokeMethod(
	Object? instance,
	MethodInfo method,
	Type[]? genericParameters,
	ReflectionWays way,
	params Object?[]? parameters
)

Parameters

instance  Object
An instance whose method is about to be invoked. This parameter is ignored for static methods.
method  MethodInfo
The method to be invoked.
genericParameters  Type
Type parameters if method is a generic method definition. Otherwise, this parameter is ignored.
way  ReflectionWays
The preferred reflection way. TypeDescriptor way is not applicable for invoking methods.
parameters  Object
The parameters to be used for invoking the method.

Return Value

Object
The return value of the method.

Remarks

If way is Auto, then the DynamicDelegate way will be used.

  Tip

To preserve the changes of a mutable value type embed it into a variable of Object type and pass it to the instance parameter of this method.

  Note

To invoke the method explicitly by dynamically created delegates use the MethodAccessor class.

See Also