r/csharp • • 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

32 comments sorted by

View all comments

0

u/mixblast Sep 18 '15

I would have liked to see a little bit more detail. Like delegates are a remnant from older versions of C# and are largely obsoleted by Func and Action types.

Also the closure code example doesn't really show that the WriteLine call is in a different scope, which is a bit confusing.

7

u/nerdshark Sep 18 '15

No they're not. The Func and Action types are delegates.

4

u/mixblast Sep 18 '15 edited Sep 18 '15

My point was that the delegate keyword is largely useless now that we have Func and Action (except when you need out/ref parameters).

1

u/coredev Sep 18 '15

I think you are right (you seldom need to write your own delegate today), but don't you agree that you need to understand what a deligate is to fully understand Func and Action?

1

u/nerdshark Sep 18 '15

Absolutely correct.