Home > Articles > Programming > Windows Programming

Programming with Generic Delegates in .NET

  • Print
  • + Share This
Generic delegates combine three powerful technologies: Lambda expressions, generics, and delegates. You'll find these elements everywhere in new versions of .NET. Paul Kimmel explains just how straightforward they really are.
Like this article? We recommend

Introduction

Sometimes I suspect that programmers learning their craft in the last five years got to skip a bunch of junk—like Dynamic Data Exchange (DDE), C, MAKE files, and assembler programming—and instead focus on the "good stuff." But, in truth, programming is evolutionary: Learning that "junk" really gives you a profound knowledge of how programs work and an easy understanding of new language features like Lambda expressions (as long as you keep learning).

The key to being a good programmer is never stop learning—and occasionally go back and fill in the blanks. Write some C and C++. Try your hand at assembler and make sure that you learn about delegates and anonymous delegates. They’ll help you to understand Lambda expressions. If you haven’t mastered generics (templates in C++), go back and study that material. Having a full toolbox of programming options is hypercritical to making magic.

In this article, we look at generic delegates; specifically, Action<T>, Func<T>, and Predicate<T>. These delegates are used everywhere in .NET now, and they encompass a lot of critical skills. Toward that end, let’s start our little odyssey.

  • + Share This
  • 🔖 Save To Your Account