Like SQL on C#
An C# extension method based on "LIKE" operator of T-SQL.
Source
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
}
}