This documentation is archived and is not being maintained.

Delegate Equality Operator

Determines whether the specified delegates are equal.

[Visual Basic]
returnValue = Delegate.op_Equality(d1, d2)
[C#]
public static bool operator ==(
 Delegate d1,
 Delegate d2
);
[C++]
public: static bool op_Equality(
 Delegate* d1,
 Delegate* d2
);
[JScript]
returnValue = d1 == d2;

[Visual Basic] In Visual Basic, you can use the operators defined by a type, but you cannot define your own. You can use the Equals method instead of the Delegate equality operator.

[JScript] In JScript, you can use the operators defined by a type, but you cannot define your own.

Arguments [Visual Basic, JScript]

d1
The first delegate to compare.
d2
The second delegate to compare.

Parameters [C#, C++]

d1
The first delegate to compare.
d2
The second delegate to compare.

Return Value

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

Remarks

Two delegates with the same methods, the same targets, and the same invocation lists are considered equal, even if they are not both multicast (combinable) or both singlecast (noncombinable).

The methods and targets are compared for equality as follows:

  • If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal.
  • If the two methods being compared are instance methods and are the same method on the same object, the methods are considered equal and the targets are also considered equal.
  • Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal.

Two invocation lists are considered identical if they have the same order and the corresponding elements from the two lists represent the same method and target.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

.NET Framework Security: 

See Also

Delegate Class | Delegate Members | System Namespace | Equals

Show: