Introduced in C# 3.0, extension methods are a valuable feature for external types, especially when those types are sealed, such as string.
Roughly two decades later, C# has now finally unveiled support for extending everything.
With the release of .NET 10 Preview 3 (C# 14), it is now possible to define static methods, instance properties, and static properties too. Support for other members will be incorporated in future releases.
Syntactically, an extension method should be defined within a top-level static class. The type of its first mandatory parameter, the one qualified with the this keyword, determines the type being extended. Henceforth, this will be referred to as the receiver type.
All standard query operators of LINQ are defined as extension methods. They are defined in the Enumerable static class within the BCL (in the System.Linq namespace).
For example, the Where extension method applies to all types that implement IEnumerable<T>. Validations and optimizations aside, the typical implementation is as outlined below.