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