ContainsAny

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!");
}

Description

Checks if a given string contains any of the string array.

Details

Double click on the code to select all.

 

;