Delegate Delegate Delegate Delegate Constructors

Definition

Overloads

Delegate(Object, String) Delegate(Object, String) Delegate(Object, String) Delegate(Object, String)

Initializes a delegate that invokes the specified instance method on the specified class instance.

Delegate(Type, String) Delegate(Type, String) Delegate(Type, String) Delegate(Type, String)

Initializes a delegate that invokes the specified static method from the specified class.

Delegate(Object, String) Delegate(Object, String) Delegate(Object, String) Delegate(Object, String)

Initializes a delegate that invokes the specified instance method on the specified class instance.

protected:
 Delegate(System::Object ^ target, System::String ^ method);
protected Delegate (object target, string method);
new Delegate : obj * string -> Delegate
Protected Sub New (target As Object, method As String)

Parameters

target
Object Object Object Object

The class instance on which the delegate invokes method.

method
String String String String

The name of the instance method that the delegate represents.

Exceptions

There was an error binding to the target method.

Remarks

This constructor cannot be used in application code. To create a delegate by specifying the name of an instance method, use an overload of the CreateDelegate method that specifies a method name and a target object. For example, the CreateDelegate(Type, Object, String) method overload creates a delegate for an instance method with a specified name.

This constructor 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.

Security

ReflectionPermission
when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). Associated enumeration: MemberAccess

See also

Delegate(Type, String) Delegate(Type, String) Delegate(Type, String) Delegate(Type, String)

Initializes a delegate that invokes the specified static method from the specified class.

protected:
 Delegate(Type ^ target, System::String ^ method);
protected Delegate (Type target, string method);
new Delegate : Type * string -> Delegate
Protected Sub New (target As Type, method As String)

Parameters

target
Type Type Type Type

The Type representing the class that defines method.

method
String String String String

The name of the static method that the delegate represents.

Exceptions

target is not a RuntimeType. See Runtime Types in Reflection.

-or-

target represents an open generic type.

Remarks

This constructor cannot be used in application code. To create a delegate by specifying the name of a static method, use an overload of the CreateDelegate method that specifies a method name but does not specify a target object. For example, the CreateDelegate(Type, Type, String) method overload creates a static delegate for a method with a specified name.

This constructor creates delegates for static 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.

Security

ReflectionPermission
when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). Associated enumeration: MemberAccess

See also

Applies to