1.2 The main purpose of extension methods is to provide for seamless integration of new functionalities to existing classes.
1.3 I have personally used extension methods to great effect in my projects and I intend to share some of my extension methods with readers in the future.
1.4 In this blog, I wish to explore how extension methods work under the hood.
1.5 We will explore low-level IL code generated for extension methods as well as their client code.
1.6 For a little bit of fun, I will also show how, with a little bit of IL code tweaking, we can turn a normal static method into an extension method.
2. A Sample Extension Method.
2.1 First let’s create a small C# class library with the following namespace and class :
using System; using System.Collections.Generic; using System.Linq; using System.Text…
View original post 2,962 more words