I am trying to replace following statement with the lambda expression:
List<ABC> l = new List<ABC>();
l.Find(delegate(ABC a) { return a.A == 4; });
I tried
l.Find((ABC a)=>a.A==4;);
but that is obviously incorrect.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Firstly, note that it is still a delegate – simply: rather, it uses the lambda syntax rather than the anonymous method syntax (it essentially means exactly the same thing, though).
As for how to fix it: just take away the
;:or more simply:
(brackets are only necessary if you have multiple parameters; explicit types are useful for disambiguation)