2

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;

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks :). It Works. I just found out, it must use bool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.