The syntax for an anonymous delegate

I seem to have problems remembering the syntax remembering the syntax for anonymous delegates, so here it is.

return GetUnfilteredList().FindAll(new Predicate<MyObject>( delegate (MyObject instance)
{
    return (instance.IsWanted));
}));

What strikes me as a write this though is how confusing it is that the delegate doesn't have a return type. Maybe that's why I can never remember the syntax.

 

Add comment

  Country flag


  • Comment
  • Preview
Loading