Table of Contents

Class Delegate

Namespace
System
Assembly
mscorlib.dll

Represents a delegate, which is a data structure that refers to a static method or to a class instance and an instance method of that class.

public abstract class Delegate
Inheritance
Delegate
Derived
Inherited Members
Extension Methods

Constructors

Delegate()

protected Delegate()

Properties

Method

Gets the method represented by the delegate.

public MethodInfo Method { get; }

Property Value

MethodInfo

A MethodInfo describing the method represented by the delegate.

Remarks

Available only in mscorlib build with support for System.Reflection.

Target

Gets the class instance on which the current delegate invokes the instance method.

public object Target { get; }

Property Value

object

The object on which the current delegate invokes the instance method, if the delegate represents an instance method; null reference (Nothing in Visual Basic) if the delegate represents a static method.

Methods

Combine(Delegate, Delegate)

Concatenates the invocation lists of two delegates.

public static Delegate Combine(Delegate a, Delegate b)

Parameters

a Delegate

The delegate whose invocation list comes first.

b Delegate

The delegate whose invocation list comes last.

Returns

Delegate

A new delegate with an invocation list that concatenates the invocation lists of a and b in that order. Returns a if b is null reference (Nothing in Visual Basic), returns b if a is a null reference, and returns a null reference if both a and b are null references.

Equals(object)

Determines whether the specified object and the current delegate are of the same type and share the same targets, methods, and invocation list.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current delegate.

Returns

bool

true if obj and the current delegate have the same targets, methods, and invocation list; otherwise, false.

GetInvocationList()

Returns the invocation list of the delegate.

public virtual Delegate[] GetInvocationList()

Returns

Delegate[]

An array of delegates representing the invocation list of the current delegate.

Remove(Delegate, Delegate)

Removes the last occurrence of the invocation list of a delegate from the invocation list of another delegate.

public static Delegate Remove(Delegate source, Delegate value)

Parameters

source Delegate

The delegate from which to remove the invocation list of value.

value Delegate

The delegate that supplies the invocation list to remove from the invocation list of source.

Returns

Delegate

A new delegate with an invocation list formed by taking the invocation list of source and removing the last occurrence of the invocation list of value, if the invocation list of value is found within the invocation list of source. Returns source if value is null reference (Nothing in Visual Basic) or if the invocation list of value is not found within the invocation list of source. Returns a null reference if the invocation list of value is equal to the invocation list of source or if source is a null reference.

Operators

operator ==(Delegate, Delegate)

Determines whether the specified delegates are equal.

public static bool operator ==(Delegate d1, Delegate d2)

Parameters

d1 Delegate

The first delegate to compare.

d2 Delegate

The second delegate to compare.

Returns

bool

true if d1 is equal to d2; otherwise, false.

operator !=(Delegate, Delegate)

Determines whether the specified delegates are not equal.

public static bool operator !=(Delegate d1, Delegate d2)

Parameters

d1 Delegate

The first delegate to compare.

d2 Delegate

The second delegate to compare.

Returns

bool

true if d1 is not equal to d2; otherwise, false.