14.9.8 Delegate equality operators

王朝other·作者佚名  2006-04-12
窄屏简体版  字體: |||超大  

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.

C# LANGUAGE SPECIFICATION

168

?If either of the delegate instances has an invocation list (?2.1)

containing one entry, they are equal if

and only if the other also has an invocation list containing one entry, and

either:

?Both refer to the same static method, or

?Both refer to the same non-static method on the same target object.

?If either of the delegate instances has an invocation list containing two

or more entries, 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 to the corresponding entry, in order, in the other?s invocation

list.

Delegates of different types can be considered equal by the above

definition, as long as they have the same

return type and parameter types.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有  導航