Created
February 26, 2013 14:46
-
-
Save FernandoVezzali/5038924 to your computer and use it in GitHub Desktop.
Extension Methods
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
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