text: Access Common Methods Using Extensions
  Extension methods are a simple way of adding common functionality to a given object in C#. It is usually faster than trying to build a new subclass from the original class and it makes your code a lot more readable. MSDN has a wonderful explanation of.
  To create an extension method, you must use this syntax:
  public static return-type MethodName(this ObjectType TheObject, ParamType1 param1, ..., ParamTypeN paramN) { /* Your actual method code here */ }
  Notice the all important this ObjectType TheObject inside the parameter list? Well this needs to match what object is actually calling it. So if you are making an extension method for a string, your first parameter will read this string YourDesiredStringName. In short: ObjectType is the name of the type that you are creating the extension method and will be stored inside TheObject property for use in the method. Any extra parameters such as param1 and so on are optional and can be used inside your method also.
  So take a look at the simple sample I have created. Notice I am calling in the namespace that contains the extensions in my main namespace, and thanks to that my int object can call all the methods naturally:
  using System; namespace MainProgram { // Call in UrdaExtensions namespace so we can access the extension methods using UrdaExtensions; class MainProgram { public static void Main() { int MyNum = 21; Console.WriteLine("MyNum = {0}\n", MyNum); Console.WriteLine("MyNum.Cube() : " + MyNum.Cube()); Console.WriteLine("MyNum.FlipInt() : " + MyNum.FlipInt()); Console.WriteLine("MyNum.ShiftTwo() : " + MyNum.ShiftTwo()); } } } namespace UrdaExtensions { public static class UrdaExtensionClass { #region Extension Methods public static int Cube(this int value) { return value * value * value; } public static int FlipInt(this int value) { char[] CharArray = value.ToString().ToCharArray(); Array.Reverse(CharArray); return int.Parse(new string(CharArray)); } public static int ShiftTwo(this int value) { return value + 2; } #endregion } } /* Program prints this to screen at runtime: MyNum = 21 MyNum.Cube() : 9261 MyNum.FlipInt() : 12 MyNum.ShiftTwo() : 23 Press any key to continue . . . */
  Thanks to extension methods, I do not have to make a call that looks something like MyUtilityObject.Cube(MyNum). Instead I can make a better method call straight from the int object. This makes life easier for all involved since the code will be much simpler to read and it allows for better code re-usability.