Search code examples
c#conventions

What does the following convention means: bool isRight = (direction== "right")


I've searched the web but didn't find a proper answer to what does the following code convention (C# in particular) means?

bool isRight = (direction == "right")

what does it means when you have the "=" and then another two "=="? I know it's kind of shortcut of writing some operations. Thanks


Solution

  • It is a shorthand for

    bool isRight = false;
    
    if (direction == "right")
    {
        isRight = true; // Change value
    }