Class Delegate
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.
Inherited Members
Namespace: System
Assembly: mscorlib.dll
Syntax
public abstract class Delegate
Properties
Method
Gets the method represented by the delegate.
Declaration
public MethodInfo Method { get; }
Property Value
Type | Description |
---|---|
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.
Declaration
public object Target { get; }
Property Value
Type | Description |
---|---|
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.
Declaration
public static extern Delegate Combine(Delegate a, Delegate b)
Parameters
Type | Name | Description |
---|---|---|
Delegate | a | The delegate whose invocation list comes first. |
Delegate | b | The delegate whose invocation list comes last. |
Returns
Type | Description |
---|---|
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.
Declaration
public extern override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object to compare with the current delegate. |
Returns
Type | Description |
---|---|
Boolean | true if obj and the current delegate have the same targets, methods, and invocation list; otherwise, false. |
Overrides
GetInvocationList()
Returns the invocation list of the delegate.
Declaration
public extern virtual Delegate[] GetInvocationList()
Returns
Type | Description |
---|---|
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.
Declaration
public static extern Delegate Remove(Delegate source, Delegate value)
Parameters
Type | Name | Description |
---|---|---|
Delegate | source | The delegate from which to remove the invocation list of value. |
Delegate | value | The delegate that supplies the invocation list to remove from the invocation list of source. |
Returns
Type | Description |
---|---|
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
Equality(Delegate, Delegate)
Determines whether the specified delegates are equal.
Declaration
public static extern bool operator ==(Delegate d1, Delegate d2)
Parameters
Type | Name | Description |
---|---|---|
Delegate | d1 | The first delegate to compare. |
Delegate | d2 | The second delegate to compare. |
Returns
Type | Description |
---|---|
Boolean | true if d1 is equal to d2; otherwise, false. |
Inequality(Delegate, Delegate)
Determines whether the specified delegates are not equal.
Declaration
public static extern bool operator !=(Delegate d1, Delegate d2)
Parameters
Type | Name | Description |
---|---|---|
Delegate | d1 | The first delegate to compare. |
Delegate | d2 | The second delegate to compare. |
Returns
Type | Description |
---|---|
Boolean | true if d1 is not equal to d2; otherwise, false. |