locked
Operator == cannot be applied to operands of type string & int RRS feed

  • Question

  • User-1499457942 posted

    Hi

      On below code i am getting above error

    if (txt_Percent.Text == 0)

    Thanks

    Saturday, October 13, 2018 7:34 PM

Answers

  • User409696431 posted

    == compares strings, not integers (or strings and integers).

    A textbox has a string in it, not an int.  If you are looking for the number zero in a textbox, it's a string.

    Try:

    if(txt_Percent.Text == "0")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 13, 2018 8:44 PM