In

public static bool In(this string s, params string[] values)
{
   return values.Any(x => x.Equals(s));
}
Example:
if (product.Category.In("Electronics", "Computers")
{
   // do something
}

Description

Returns true if this string is any of the provided strings. Equivalent to IN operator in SQL. It eliminates the need to write something like 'if (foo == "foo1" || foo == "foo2" || foo == "foo3")'

Details

Double click on the code to select all.

 

;