9.5.2 Pre-processing expressions

博客主要介绍了C#中预处理表达式,其可出现在#if和#elif指令中,允许使用!, ==,!=, &&和||运算符,可用括号分组。还给出了预处理表达式的语法规则,且引用时,已定义和未定义的条件编译符号分别有布尔值true和false,求值结果为布尔值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

9.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.
pp-expression::
whitespaceopt pp-or-expression whitespaceopt
pp-or-expression::
pp-and-expression
pp-or-expression whitespaceopt || whitespaceopt pp-and-expression
pp-and-expression::
pp-equality-expression
pp-and-expression whitespaceopt && whitespaceopt pp-equality-expression
pp-equality-expression::
pp-unary-expression
pp-equality-expression whitespaceopt == whitespaceopt pp-unary-expression
pp-equality-expression whitespaceopt != whitespaceopt pp-unary-expression
pp-unary-expression::
pp-primary-expression
! whitespaceopt pp-unary-expression
C# LANGUAGE SPECIFICATION
64
pp-primary-expression::
true
false
conditional-symbol
( whitespaceopt pp-expression whitespaceopt )
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 preprocessing
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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值