Trick to OR Operator

Is it possible to doe something like:

if (PlayerPrefs.GetString ("Something") == ("OneThing" || "AnotherThing" || "ThirdThing")) {
}

Or would I have to do:

if (PlayerPrefs.GetString ("Something") == "OneThing" || PlayerPrefs.GetString ("Something") ==  "AnotherThing" || PlayerPrefs.GetString ("Something") ==  "ThirdThing") {
}

It may be a tiny performance hit, but if you’re looking for quick testing you could put the valid strings into a list or array, and check if the array contains the value being tested.

For example, a simple filter might look like this:

public void SomeFunction()
{
    string result = PlayerPrefs.GetString("MyStringValue");
    List<string> goodResults = new List<string>()
        {"good", "better", "best"};
    
    if (goodResults.Contains(result)) 
    {
         // do good stuff   
    }

    // optionally check other lists.
}

At the very least, I would cache the result of the player refs getter to save yourself some keystrokes and lookups, by storing it in a local variable like above with ‘result’ (though ideally more appropriately named).

[Edit]: If things start to get complicated you may want to also consider using a switch statement. You can fall through cases if they are left blank, allowing you to use it like a chained if / or series, as well as else-ifs.

    switch(mystring)
    {
        case "optionA":
        case "optionB":
	    case "optionC":
	        //do stuff if == optionA, optionB, or optionC
	        break;
	    case "optionD":
        case "optionE":
	        // do stuff if == optionD or optionE
	        break;
        case "optionF":
            // do stuff if == optionF
            break;
        default: 
             // do stuff if none of the above
             break;
    }