ExtensionMethod.NET Home of 829 C#, Visual Basic, F# and Javascript extension methods


Check that the given string is in a list of potential matches. Inspired by StackOverflow answer http://stackoverflow.com/a/20644611/23199


public static bool EqualsAny(this string str, params string[] args) 
    return args.Any(x=> 
      StringComparer.InvariantCultureIgnoreCase.Equals(x, str));		


string custName = "foo";
bool isMatch = (custName.EqualsAny("bar", "baz", "FOO")); //true

Author: Phil Campbell

Submitted on: 17 dec 2013

Language: C#

Type: System.String

Views: 5026