BalAzs
0
Q:

define extension methods c#

public static class MyExtensions
{
  //use the this keyword before an argument
  public static int WordCount(this String str)
  {
    return str.Split(new char[] { ' ', '.', '?' },
                     StringSplitOptions.RemoveEmptyEntries).Length;
  }
}
1

New to Communities?

Join the community