DelegateCreateDelegate Method (Type, Type, String) |
Creates a delegate of the specified type that represents the specified static method of the specified class.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static Delegate CreateDelegate(
Type type,
Type target,
string method
)
Parameters
- type
- Type: SystemType
The Type of delegate to create. - target
- Type: SystemType
The Type representing the class that implements method. - method
- Type: SystemString
The name of the static method that the delegate is to represent.
Return Value
Type:
DelegateA delegate of the specified type that represents the specified static method of the specified class.
Exceptions Exception | Condition |
---|
ArgumentNullException | type is null.-or- target is null.-or- method is null. |
ArgumentException | type does not inherit MulticastDelegate.-or- type is not a RuntimeType. See Runtime Types in Reflection. -or-target is not a RuntimeType.-or-target is an open generic type. That is, its ContainsGenericParameters property is true.-or-method is not a static method (Shared method in Visual Basic). -or-method cannot be bound, for example because it cannot be found, and throwOnBindFailure is true. |
MissingMethodException | The Invoke method of type is not found. |
MethodAccessException | The caller does not have the permissions necessary to access method. |
See Also