[英]C# & operator problem
How do I use the &
binary operator correctly? 如何正确使用
&
二元运算符? randomSize is ushort. randomSize是ushort。
if (randomSize & 0x1000)
{
}
Error 5 Cannot implicitly convert type 'int' to 'bool' 错误5无法将类型'int'隐式转换为'bool'
Thanks. 谢谢。
The if
statement expects a bool
value, not just some non-zero value like in C/C++. if
语句需要一个bool
值,而不仅仅是像C / C ++中那样的非零值。 If you are checking flags, try something like this: 如果要检查标志,请尝试以下方法:
if ((randomSize & 0x1000) == 0x1000)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.