its pretty simple
int WordCount=1;
foreach(char i in s)
{
foreach (char i in s)
{
if (char.IsWhiteSpace(i))
WordCount++;
}
}
but words can be separated by spaces,comma,punctuation etc.
so in this case,create a string which contains all word separaters
eg:string Separators=",. \'\"?!";//there are more. add it in any order
now replace
if (char.IsWhiteSpace(i))
WordCount++;
by
if (Separators.Contains(i))
WordCount++;
Print out WordCount at last to get number of words.
this would be the simplest solution :D