X hits on this document

799 views

0 shares

0 downloads

0 comments

175 / 396

C# LANGUAGE SPECIFICATION

Enumeration member declarations (§‎14.3).

case labels of a switch statement (§‎8.7.2).

goto case statements (§‎8.9.3).

Dimension lengths in an array creation expression (§‎7.5.10.2) that includes an initializer.

Attributes (§‎17).

An implicit constant expression conversion (§‎6.1.6) permits a constant expression of type int to be converted to sbyte, byte, short, ushort, uint, or ulong, provided the value of the constant expression is within the range of the destination type.

7.16 Boolean expressions

A boolean-expression is an expression that yields a result of type bool.

boolean-expression: expression

The controlling conditional expression of an if-statement (§‎8.7.1), while-statement‎8.8.1), do-statement (§‎8.8.2), or for-statement‎8.8.3) is a boolean-expression. The controlling conditional expression of the ?: operator (§‎7.12) follows the same rules as a boolean-expression, but for reasons of operator precedence is classified as a conditional-or-expression.

A boolean-expression is required to be of a type that can be implicitly converted to bool or of a type that implements operator true. If neither requirement is satisfied, a compile-time error occurs.

When a boolean expression is of a type that cannot be implicitly converted to bool but does implement operator true, then following evaluation of the expression, the operator true implementation provided by that type is invoked to produce a bool value.

The DBBool struct type in §‎11.4.2 provides an example of a type that implements operator true and operator false.

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

Document info
Document views799
Page views799
Page last viewedSun Dec 04 01:03:40 UTC 2016
Pages396
Paragraphs9401
Words133190

Comments