Home > DeveloperSection > Forums > how to Convert Lambda expression to Func<> variable
Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    August-18-2014 3:27 AM

 C# C# 

 1 Reply(s)
 1338  View(s)
Rate this:

I have code for searching file. And now have Lambda Expression for filtering that.How to convert the Expression to Func<string> variable. Thanks

Code :

Directory.GetFiles(folder, "*" + KeyWord + "*").Where(f => formatFile.Contains(f.Split('.').Last().ToLower()));

into variable :

Func<string> Lambda = ?? (f => formatFile.Contains(f.Split('.').Last().ToLower())) \\ convert the Expression;

Pravesh Singh

Total Post:412

Posted on    August-18-2014 3:49 AM

Hi Ankita,

Try this :

Func<string,bool> lambda = f => formatFile.Contains(f.Split('.').Last().ToLower());

Don't want to miss updates? Please click the below button!

Follow MindStick