This is simple word count extension method.
public static class StringExtension
{
public static int WordCount(this string s)
{
int count = 0;
for (int i = 0; i < s.Length; i++)
{
if (s[i] != ' ')
{
if ((i + 1) == s.Length)
{
count++;
}
else
{
if (s[i + 1] == ' ')
{
count++;
}
}
}
}
return count;
}
}
Just tell me reason why extension method is static and why it is wrapped in static class ?