Created
May 7, 2012 12:17
-
-
Save tnngo2/2627468 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Theory10 | |
{ | |
/// <summary> | |
/// Class ExtensionExample defines the extension method | |
/// </summary> | |
static class ExtensionExample | |
{ | |
// Extension Method to convert the fist character to | |
// lowercase | |
public static string FirstLetterLower(this string result) | |
{ | |
if (result.Length > 0) | |
{ | |
char[] s = result.ToCharArray(); | |
s[0] = char.ToLower(s[0]); | |
return new string(s); | |
} | |
return result; | |
} | |
} | |
class Run | |
{ | |
public static void Main(string[] args) | |
{ | |
string country = "Great Britain"; | |
// Calling the extension method | |
Console.WriteLine(country.FirstLetterLower()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment