EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

Delegate.CreateDelegate Method (Type, Object, String, Boolean)

May 11, 2014

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.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Déclaration
Public Shared Function CreateDelegate ( _
	type As Type, _
	target As Object, _
	method As String, _
	ignoreCase As Boolean _
) As Delegate

Parameters

type
Type: System.Type
The type of delegate to create.
target
Type: System.Object
The class instance on which method is invoked.
method
Type: System.String
The name of the instance method that the delegate is to represent.
ignoreCase
Type: System.Boolean
true to ignore the case when comparing the name of the method; otherwise, false.

Return Value

Type: System.Delegate
A delegate of the specified type that represents the specified instance method to invoke on the specified class instance.

ExceptionCondition
ArgumentNullException

type is Nothing.

-or-

target is Nothing.

-or-

method is Nothing.

ArgumentException

type does not inherit MulticastDelegate.

-or-

type is not a RuntimeType.

-or-

method is not an instance method.

-or-

method cannot be bound; for example, because it cannot be found.

MissingMethodException

The Invoke method of type is not found.

MethodAccessException

The caller does not have access to method.

-or-

Application code attempts to access this member late-bound, for example, by using the Type.InvokeMember method.

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.

method must specify an accessible method.

This method overload is equivalent to calling the CreateDelegate(Type, Object, String, Boolean, Boolean) method overload, and specifying true for throwOnBindFailure.

Platform Notes

 CreateDelegate throws MissingMethodException when attempting to create a delegate with incorrect arguments. Delegate.CreateDelegate throws TargetInvocationException when called on a null object. Delegate.CreateDelegate throws MissingMethodException instead of ArgumentException for non-instance methods.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Afficher:
© 2014 Microsoft