X hits on this document

975 views

0 shares

0 downloads

0 comments

167 / 396

C# LANGUAGE SPECIFICATION

Otherwise, if an implicit reference conversion (§‎6.1.4) or boxing conversion (§‎6.1.5) exists from the compile-time type of e to T, this conversion is performed and becomes the result of the operation.

Otherwise, if an explicit reference conversion (§‎6.2.3) exists from the compile-time type of e to T, a dynamic type check is performed:

If the value of e is null, the result is the value null with the compile-time type T.

Otherwise, let R be the run-time type of the instance referenced by e. If R and T are the same type, if R is a reference type and an implicit reference conversion from R to T exists, or if R is a value type and T is an interface type that is implemented by R, the result is the reference given by e with the compile-time type T.

Otherwise, the result is the value null with the compile-time type T.

Otherwise, the indicated conversion is never possible, and a compile-time error occurs.

Note that the as operator only performs reference conversions and boxing conversions. Other conversions, such as user defined conversions, are not possible with the as operator and should instead be performed using cast expressions.

7.10 Logical operators

The &, ^, and | operators are called the logical operators.

and-expression: equality-expression and-expression   &   equality-expression

exclusive-or-expression: and-expression exclusive-or-expression   ^   and-expression

inclusive-or-expression: exclusive-or-expression inclusive-or-expression   |   exclusive-or-expression

For an operation of the form x op y, where op is one of the logical operators, overload resolution (§‎7.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 logical operators are described in the following sections.

7.10.1 Integer logical operators

The predefined integer logical operators are:

int operator &(int x, int y); uint operator &(uint x, uint y); long operator &(long x, long y); ulong operator &(ulong x, ulong y);

int operator |(int x, int y); uint operator |(uint x, uint y); long operator |(long x, long y); ulong operator |(ulong x, ulong y);

int operator ^(int x, int y); uint operator ^(uint x, uint y); long operator ^(long x, long y); ulong operator ^(ulong x, ulong y);

154Copyright Microsoft Corporation 1999-2003. All Rights Reserved.

Document info
Document views975
Page views975
Page last viewedThu Dec 08 22:28:28 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments