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

后端 未结 3 1049
臣服心动
臣服心动 2021-01-02 20:24

This program is in response to the assignment:

\"Create a method named Sum() that accepts any number of integer parameters and displays their sum. Writ

相关标签:
3条回答
  • 2021-01-02 20:57

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

    (Convert.ToInt32(q) == 1)
    
    0 讨论(0)
  • 2021-01-02 21:11

    I got this error and many others when I inadvertently opened a solution with Visual Studio 2015 when it had been developed in VS2017.

    Other errors included:

    ; expected

    } expected

    0 讨论(0)
  • 2021-01-02 21:12

    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.

    0 讨论(0)
提交回复
热议问题