I'd like to be able to write something like the following. Can someone show me how to write a clean WordReader class in C#. (a word is [a-zA-Z]+)
public List<string> GetSpecialWords(string text)
{
string word;
List<string> specialWords = new List<string>();
using (WordReader wr = new WordReader(text))
{
while (true)
{
word = wr.Read();
if (word == null) break;
if (isSpecial(word)) specialWords.Add(word);
}
}
return specialWords;
}
private bool isSpecial(string word)
{
//some business logic here
}