Search⌘ K
AI Features

What Are Extension Methods?

Explore how to write and apply extension methods in C#. Understand their structure, how they extend existing types like strings, and how they support LINQ operations such as filtering with the Where method.

We need extension methods because LINQ uses extensions methods on the IEnumerable type. And, we’ll likely find extension methods handy outside this course too.

We can add new methods to a type without modifying it with extension methods. They are static methods defined outside the declaration of a type. But we use extension methods the same way we use typical ...