Sure, string has a member method of Contains, but its an exact comparison. What I really want is something that takes a StringComparison argument as well.
public static bool Contains(this string source, string search, StringComparison comparison)
{
return source.IndexOf(source, 0, comparison) > -1;
}
Not much to this extension method, but it gives me the semantics that I want.
if (foo.Contains("bar", StringComparison.CurrentCultureIgnoreCase)) …