Wednesday, December 10, 2014

New Video Series: C# Delegates

I've been talking about delegates for several years now. As with most of my topics, this is something that took a while for me to wrap my head around. But once I "got it", I saw how useful delegates are. They let us use methods as parameters to other methods -- this let's us incorporate functional-style programming into our C# code. In addition, since lambda expressions are simply anonymous delegates, they are much easier to understand once we have a good handle on what standard delegates are.

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.
For the sample code and supplemental articles, head over to my website: Get Func<>-y: Delegates in .NET

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.

Happy Coding!

No comments:

Post a Comment