Like SQL on C#

public static class StringExtensions
{
	public static bool Like(this string value, string search)
	{
		return value.Contains(search) || value.StartsWith(search) || value.EndsWith(search);
	}
}
Example:
using System;
using System.Collections.Generic;

					
public class Program
{
	public static void Main()
	{
		string stringValue = "the brown fox jumped over the lazy dog";
		string searchCondition = "fox";
		
		Console.WriteLine(stringValue.Like(searchCondition));
//Will Return True
	}
}

Description

An C# extension method based on "LIKE" operator of T-SQL.

Details

Double click on the code to select all.

 

;