다음을 통해 공유


Delegate.Equals Method

Determines whether the specified object and the current singlecast (noncombinable) delegate share the same target, method, and invocation list.

Overrides Public Function Equals( _
   ByVal obj As Object _) As Boolean
[C#]
public override bool Equals(objectobj);
[C++]
public: bool Equals(Object* obj);
[JScript]
public override function Equals(
   obj : Object) : Boolean;

Parameters

  • obj
    The object to compare with the current singlecast (noncombinable) delegate.

Return Value

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

Exceptions

Exception Type Condition
MemberAccessException The caller does not have access to the method represented by the delegate (for example, if the method is private).

Remarks

This method applies only if the current delegate is singlecast (noncombinable).

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 only 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:

  • ReflectionPermission when invoked late-bound through mechanisms such as Type.InvokeMember. Associated enumeration: ReflectionPermissionFlag.MemberAccess

See Also

Delegate Class | Delegate Members | System Namespace | Object