Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 30th, 2012  |  syntax: None  |  size: 0.80 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2.  
  3. namespace Theory10
  4. {
  5.     /// <summary>
  6.     /// Class ExtensionExample defines the extension method
  7.     /// </summary>
  8.     static class ExtensionExample
  9.     {
  10.         // Extension Method to convert the fist character to          
  11.         // lowercase
  12.         public static string FirstLetterLower(this string result)
  13.         {
  14.             if (result.Length > 0)
  15.             {
  16.                 char[] s = result.ToCharArray();
  17.                 s[0] = char.ToLower(s[0]);
  18.                 return new string(s);
  19.             }
  20.             return result;
  21.         }
  22.     }
  23.  
  24.     class Run
  25.     {
  26.         public static void Main(string[] args)
  27.         {
  28.             string country = "Great Britain";
  29.             // Calling the extension method
  30.             Console.WriteLine(country.FirstLetterLower());
  31.         }
  32.     }
  33.  
  34.  
  35. }