Вопрос

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;
Это было полезно?

Решение

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).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top