1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
   | namespace ExtensionMethods {     public static class MyExtensions     {                  public static int WordCount(this string str)         {             return str.Split(new char[]{' ', '.', '?'},                 StringSplitOptions.RemoveEmptyEntires).Length;         }     } }
  using ExtensionMethods;
  string s = "Hello Extension Methods"; int length = s.WordCount();
   |