Question

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;
Was it helpful?

Solution

It should be as easy as:

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

The bool seems to be the part you were missing (this expression takes a string and returns a bool).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top