System.Delegate.CreateDelegate Method

Creates a delegate of the specified type that represents the specified instance method to invoke on the specified class instance, with the specified case-sensitivity and the specified behavior on failure to bind.

Syntax

public static Delegate CreateDelegate (Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure)

Parameters

type
The Type of delegate to create.
target
The class instance on which method is invoked.
method
The name of the instance method that the delegate is to represent.
ignoreCase
A Boolean indicating whether to ignore the case when comparing the name of the method.
throwOnBindFailure
true to throw an exception if method cannot be bound; otherwise, false.

Returns

A delegate of the specified type that represents the specified instance method to invoke on the specified class instance.

Remarks

This method creates delegates for instance methods only. An instance method is a method that is associated with an instance of a class; a static method is a method that is associated with the class itself.

Note:

Starting with the net_v20sp1_long, this method can be used to access non-public methods if the caller has been granted System.Security.Permissions.ReflectionPermission with the System.Security.Permissions.ReflectionPermissionFlag.RestrictedMemberAccess flag and if the grant set of the non-public methods is restricted to the caller’s grant set, or a subset thereof. (See Security Considerations for Reflection.)

To use this functionality, your application should target the net_v35_long or later.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0