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
- Author: kevinjong
- Submitted on: 3/24/2010 7:56:50 AM
- Language: C#
- Type: System.String
- Views: 2306
Double click on the code to select all.