Delegate equality operators
Every delegate type implicitly provides the following predefined comparison operators: bool operator ==(System.Delegate x, System.Delegate y); bool operator!=(System.Delegate x, System.Delegate y); Two delegate instances are considered equal as follows: · If either of the delegate instances is null, they are equal if and only if both are null. · If the delegates have different run-time type they are never equal. · If both of the delegate instances have an invocation list (§15.1), those instances are equal if and only if their invocation lists are the same length, and each entry in one’s invocation list is equal (as defined below) to the corresponding entry, in order, in the other’s invocation list. The following rules govern the equality of invocation list entries: · If two invocation list entries both refer to the same static method then the entries are equal. · If two invocation list entries both refer to the same non-static method on the same target object (as defined by the reference equality operators) then the entries are equal. · Invocation list entries produced from evaluation of semantically identical anonymous-function-expressions with the same (possibly empty) set of captured outer variable instances are permitted (but not required) to be equal.
|