ReflectorInvokeMethod(Type, String, Boolean, Object) Method

Invokes a static method of a Type represented by the specified methodName.

Definition

Namespace: KGySoft.Reflection
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
C#
public static Object? InvokeMethod(
	Type type,
	string methodName,
	bool ignoreCase,
	params Object?[]? parameters
)

Parameters

type  Type
The Type the static method belongs to.
methodName  String
The name of the method to be invoked.
ignoreCase  Boolean
to ignore case; to regard case.
parameters  Object
The parameters to be used for invoking the method.

Return Value

Object
The return value of the method.

Remarks

methodName can refer public and non-public methods. To avoid ambiguity this method gets all the methods of the same name and chooses the first one for which the provided parameters match.

If you already have a MethodInfo instance use the InvokeMethod(Object, MethodInfo, Type, ReflectionWays, Object) method for better performance.

If you are not sure whether a method with the specified methodName exists, then you can use the TryInvokeMethod methods instead.

For invoking the method this method uses the DynamicDelegate reflection way.

See Also