Skip to content

Instantly share code, notes, and snippets.

@FernandoVezzali
Created February 26, 2013 14:46
Show Gist options
  • Save FernandoVezzali/5038924 to your computer and use it in GitHub Desktop.
Save FernandoVezzali/5038924 to your computer and use it in GitHub Desktop.
Extension Methods
class Program
{
static void Main()
{
string s = "Hello Extension Methods";
int i = s.WordCount();
}
}
public static class MyExtensions
{
public static int WordCount(this String str)
{
return str.Split(new char[] { ' ', '.', '?' },
StringSplitOptions.RemoveEmptyEntries).Length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment