The checked and unchecked statements are used to control the overflow
checking context for integraltype
arithmetic operations and conversions.
checked-statement:
checked block
unchecked-statement:
unchecked block
The checked statement causes all expressions in the block to be evaluated
in a checked context, and the
unchecked statement causes all expressions in the block to be evaluated in
an unchecked context.
The checked and unchecked statements are precisely equivalent to the
checked and unchecked
operators (§14.5.12), except that they operate on blocks instead of
expressions.
checking context for integraltype
arithmetic operations and conversions.
checked-statement:
checked block
unchecked-statement:
unchecked block
The checked statement causes all expressions in the block to be evaluated
in a checked context, and the
unchecked statement causes all expressions in the block to be evaluated in
an unchecked context.
The checked and unchecked statements are precisely equivalent to the
checked and unchecked
operators (§14.5.12), except that they operate on blocks instead of
expressions.
本文详细介绍了C#中的checked和unchecked语句的作用,这两种语句分别用于控制整型算术运算和转换过程中是否开启溢出检查。checked语句使块内的所有表达式处于检查上下文中,而unchecked语句则关闭溢出检查。
644

被折叠的 条评论
为什么被折叠?



