Skip to content

Instantly share code, notes, and snippets.

@tnngo2
Created May 7, 2012 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnngo2/2627468 to your computer and use it in GitHub Desktop.
Save tnngo2/2627468 to your computer and use it in GitHub Desktop.
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