ECMA-334 C# Language Specification9.5.2: Pre-processing expressions |
Pre-processing expressions can occur in #if
and #elif
directives. The operators !, ==, !=, && and || are permitted in pre-processing expressions, and parentheses may be used for grouping.
whitespace
opt pp-or-expression
whitespace
opt pp-and-expression
pp-or-expression
whitespace
opt ||
whitespace
opt pp-and-expression
pp-equality-expression
pp-and-expression
whitespace
opt &&
whitespace
opt pp-equality-expression
pp-unary-expression
pp-equality-expression
whitespace
opt ==
whitespace
opt pp-unary-expression
pp-equality-expression
whitespace
opt !=
whitespace
opt pp-unary-expression
pp-primary-expression
!
whitespace
opt pp-unary-expression
conditional-symbol
(
whitespace
opt pp-expression
whitespace
opt )
When referenced in a pre-processing expression, a defined conditional compilation symbol has the boolean value true, and an undefined conditional compilation symbol has the boolean value false.
Evaluation of a pre-processing expression always yields a boolean value. The rules of evaluation for a pre-processing expression are the same as those for a constant expression (14.15), except that the only user-defined entities that can be referenced are conditional compilation symbols.