none
if(1 or 2) //strings

    Question

  • Hello I want to use if statement with or(||, |) but with strings no int

    e.x

    int a = 1;

    int b = 2;

    if(a = 1 || b = 5)

    { //some code }

    but I want something like this:

    string a = "Hello";

    string b = "Goodbye";

    if(a = "Hello" || b = "Goodbye")

    { //some code }

    how I can do that because || is ony for int

    Saturday, April 8, 2017 7:13 PM

Answers

  • how I can do that because || is ony for int

    Nope. It's not for int, it's for boolean. Means that you have to OR two boolean conditions:

    if (a == "Hello" || b == "Goodbye")

    Note the double "==" instead of the single "=". This also goes for ints, not just for strings.


    Saturday, April 8, 2017 7:35 PM
    Moderator