How to combine || operators in condition statement [duplicate]

Unfortunately not, your best bet is to create an extension method

public static bool IsOneOf<T>(this T value, params T[] options)
{
    return options.Contains(value);
}

and you can use it like this:

if (foo.IsOneOf("1", "5", "9"))
{
    ...
}

Being generic, it can be used for any type (int, string etc).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)