You can use the extension methods available in .NET 3.5 for syntax like
if (myString.InList("this", "that", "the other thing")) {}
Just add something like this (and import it):
public static bool InList(this string text, params string[] listToSearch) { foreach (var item in listToSearch) { if (string.Compare(item, text, StringComparison.CurrentCulture) == 0) { return true; } } return false; }
If you are using an older version, you can still use this function, but you will need to call it like this:
if (InList(myString, "this", "that", "the other thing")) {}
Of course, in the InList function, delete this keyword.
source share