Course info
Jun 4, 2021
2h 40m
Your 10-day individual free trial includes:

Expert-led courses

Keep up with the pace of change with thousands of expert-led, in-depth courses.

In this course, Working With C# Generics: Best Practices, you’ll learn to use generics in your own types and classes. First, you’ll explore generic interfaces and constraints. Next, you’ll discover the covariance and contravariance. Finally, you’ll learn how to use generics with events and methods. When you’re finished with this course, you’ll have the skills and knowledge of C# generics needed to level up your .NET apps with cleaner, more reusable code.

About the author
About the author

Steve Smith (@ardalis) is an entrepreneur and software developer with a passion for building quality software as effectively as possible.

More from the author
Domain-Driven Design Fundamentals
4h 47m
May 14, 2021
Kanban: Getting Started
2h 16m
Jan 22, 2021
More courses by Steve Smith
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi there. My name is Steve Smith, aka Ardalis, and welcome to my course, C# Generics: Best Practices. I've been working with and teaching students how to be productive with C# since the first version of C# and .NET shipped. My company, NimblePros, helps teams write better code faster, and that's really my motivation for sharing tips and techniques with you here on Pluralsight too. My hope is that after watching this course, even if you've been using generics, you'll have a few new tips or techniques you can apply to your applications. Although generics have been a feature of .NET and C# since about 2005, they've continued to evolve as other new features have been added. Today, I can't imagine writing .NET apps without generics. In this course, we are going to cover some best practices for getting the most out of C# generics. We'll talk about the basics of the features, yes, but we'll go beyond that to show not just how it works, but when and where you should apply them in real code. Some of the major topics that we will cover include how can generic constraints improve your design, when should you use a generic interface, class or method, how can you finally remember the difference between covariance and contravariance, when would you use reflection with generics, and how can you write more flexible code with generic events and delegate types? By the end of this course, you'll be able to apply generics in new and better ways in your applications. You'll be introduced to built‑in types and NuGet packages that can take your generic code usage to the next level. I hope you'll join me in learning how to make the most out of using generics in your C# applications, here in this Pluralsight course.