Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
29 lines (22 sloc) 643 Bytes
namespace tdddemoapp
{
public class TextAnalyzer
{
public int GetTotalWordCount(string text)
{
int wordCount = 0, index = 0;
while (index < text.Length)
{
// check if current char is part of a word
while (index < text.Length && !char.IsWhiteSpace(text[index]))
index++;
wordCount++;
// skip whitespace until next word
while (index < text.Length && char.IsWhiteSpace(text[index]))
index++;
}
return wordCount;
}
}
}