ContainsAny
Checks if a given string contains any of the string array.
Source
public static bool ContainsAny(
this string value,
params string[] values)
{
foreach (string one in values)
{
if (value.Contains(one))
{
return true;
}
}
return false;
}
Example
string value = "Kevin from Taiwan.";
string[] values = new string[] { "Kevin", "Sunny" };
if(value.ContainsAny(values))
{
Console.WriteLine("Hi!");
}