Getting closer to extension methods
An extension method is a capability that can extend the ability of an existing class or type without making any modification to the existing class or type. This means that an extension method enables us to add methods to the existing class or type without having to either create a new derived type or recompile.
Extension methods were introduced in C# 3.0 and can be applied to our own types or existing types in .NET. The extension method will be used a lot in functional programming since it suits the method chaining concept, which we have already used in Chapter 1, Tasting Functional Style in C#, when refactoring code in a functional style.
Creating an extension method
Extension methods have to be declared in a static, nongeneric, and non-nested class. They are a static method inside a static class. To create an extension method, first we have to create a public static
class since the extension methods have to be included in the static
class. After the public...