The type of the operand expression of the unary ! operator must be boolean or Boolean, or a compile-time error occurs. The type of the unary logical complement expression is boolean.
At run time, the operand is subject to unboxing conversion if necessary; the value of the unary logical complement expression is true if the (possibly converted) operand value is false and false if the (possibly converted) operand value is true.
# 1 楼答案
使用
!
一元数boolean
逻辑补码运算符:参考文献
测试
if (!something)
的另一个选项是测试if (something == false)
相关问题