Donate

Match Item That Exists In A List Using Regular Expression And LINQ

Hi!
Using Any() in LINQ, we can match/find an item that exists in a List<T> or IEnumerable using Regular Expressions.
if(Products.Any(t => Regex.IsMatch(t, ProductsFromFrance.FrenchProdPattern))
{
   //true statement here..
}
Where Products is the List object and ProductsFromFrance.FrenchProdPattern is the Regular Expression pattern.

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.