EqualsAny
public static bool EqualsAny(this string str, params string[] args) { return args.Any(x=> StringComparer.InvariantCultureIgnoreCase.Equals(x, str)); }Example:
string custName = "foo"; bool isMatch = (custName.EqualsAny("bar", "baz", "FOO")); //true
Description
Check that the given string is in a list of potential matches. Inspired by StackOverflow answer http://stackoverflow.com/a/20644611/23199
Details
- Author: Phil Campbell
- Submitted on: 12/17/2013 11:56:34 PM
- Language: C#
- Type: System.String
- Views: 3165
Double click on the code to select all.