Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • I know they exist - I get that the answer to "Why should I learn them" is "Because you need them to interact with stuff that requires them." My question is "Why does stuff require them in the first place? What code are you writing where you think 'You know what I need here? A delegate!'?" Commented Sep 12, 2013 at 13:48
  • Because there is no other way to pass a piece of code to a method in C#. The APIs exposed in those 3 libraries are some of the best, in my opinion. Try to imagine how you would make a similar library without delegates (aside from true first-class functions); you would not be able to. msdn.microsoft.com/en-us/library/dd460720.aspx Try rewriting Parallel.ForEach without delegates. Commented Sep 12, 2013 at 13:53
  • I could write "Parallel.ForEach" without delegates easy, but not in C#. There is some issue with C# that C++ doesn't have because I wouldn't need a delegate to do it in C++. Commented Sep 12, 2013 at 14:01
  • stackoverflow.com/questions/10766139/… great explanation there. Although, I prefer F#'s first class function system, C#'s is easier to understand once you come to terms with HAVING to declare the delegate signature and name it OR using a "built in" one. Commented Sep 12, 2013 at 14:11
  • @medivh What would you use? Functors? Functors in C++ and delegates in C# fulfill the same role (even if the technicalities are different). Commented Sep 12, 2013 at 16:42