Pergunta

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;
Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top