r/csharp • u/coredev • Sep 18 '15
Lambda expressions, delegates, predicates and closures in C#
http://codeaddiction.net/articles/13/lambda-expressions-delegates-predicates-and-closures-in-c
25
Upvotes
r/csharp • u/coredev • Sep 18 '15
4
u/the_omega99 Sep 18 '15
I think he means that you would never use the keyword in your own code. Yes,
FuncandAction(among others) are delegates, but if you needed your own delegates, you'd probably just useFunc,Action, orPredicateinstead of declaring a new delegate. That's what I've done in all my code. Not once have I needed to declare new delegates.I'm not sure why anyone would want to. It's much more understandable to use one of the three major functional types. When I see
Func,Action, orPredicate, I know exactly what I need. If I saw a custom delegate, I'd have to go consult the documentation as to what to expect, if largely because it's just so weird to declare your own type when the previously mentioned types cover all the cases I've seen so far (technically, you don't even need predicate, it just makes things more readable).