14.9 Relational & type-testing operators

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

The ==, !=, <, >, <=, >=, is and as operators are called the relational and

type-testing operators.

relational-expression:

shift-expression

relational-expression < shift-expression

relational-expression > shift-expression

relational-expression <= shift-expression

relational-expression >= shift-expression

relational-expression is type

relational-expression as type

C# LANGUAGE SPECIFICATION

164

equality-expression:

relational-expression

equality-expression == relational-expression

equality-expression != relational-expression

The is operator is described in ?4.9.9 and the as operator is described in

?4.9.10.

The ==, !=, <, >, <= and >= operators are comparison operators. For an

operation of the form x op y,

where op is a comparison operator, overload resolution (?4.2.4) is applied

to select a specific operator

implementation. The operands are converted to the parameter types of the

selected operator, and the type of

the result is the return type of the operator.

The predefined comparison operators are described in the following

sections. All predefined comparison

operators return a result of type bool, as described in the following table.

Operation Result

x == y true if x is equal to y, false otherwise

x != y true if x is not equal to y, false otherwise

x < y true if x is less than y, false otherwise

x > y true if x is greater than y, false otherwise

x <= y true if x is less than or equal to y, false otherwise

x >= y true if x is greater than or equal to y, false otherwise

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