To help other folks "get" delegates, I just put together a video series on C# Delegates. Check it out on YouTube.
C# Delegates (Playlist)
Do you use delegates in .NET? If so, then Func and Action are just waiting to make your life easier. Not using delegates? Maybe you should. We'll take a look at what delegates are, why you would want to use them, and how to use Func and Action to tie things all together (with a few Lambdas thrown in just for fun).
- Part 1: Basics
In this video (first of a series), we'll look at the basics of delegates, including how to create a new delegate type, how to pass a delegate as a parameter to a method, and how to select what method we execute at runtime rather than compile-time. Along the way, we'll see how delegates can help us adhere to the S.O.L.I.D. principles.
- Part 2: Getting Func<>-y (+ Lambdas)
In this video, we'll see how we can use the built-in delegate type "Func" instead of using a custom delegate. In addition, we'll see how lambda expressions can make our code very compact and easy to read.
- Part 3: Action<> and Multicast Delegates
In this video, we'll use the built-in "Action" delegate. Along the way, we'll see how multicast delegates allow us to run multiple methods by invoking a single delegate variable.
So in less than an hour, you can understand delegates a bit better. They are pretty awesome. And it's an important step to get a firm grasp one of my favorite topics: lambda expressions.