CS0019 Operator cannot be applied to operands of type 'bool' and 'int'

心不动则不痛 提交于 2019-11-30 14:52:05

You can't write (q == 1) in C#, because q is a bool and 1 is an int.

q can only be compared to another boolean expression, e.g. true, false, another boolean variable, etc.

Just if someone read this question and needs comparing a bool with an int:

(Convert.ToInt32(q) == 1)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!