Is there a better way than the following brute foce implementation of a c# word counting class?
UPDATED CODE: Sorry!
/// <summary>
/// A word counting class.
/// </summary>
public class WordCounter
{
Dictionary<string, int> dictTest = new Dictionary<string, int> ();
/// <summary>
/// Enters a word and returns the current number of times that word was found.
/// </summary>
/// <param name="word">The word or string found.</param>
/// <returns>Count of times Found() was called with provided word.</returns>
public int Found ( string word )
{
int count = 1;
return dictTest.TryGetValue ( word, out count ) ? ++dictTest[word] : dictTest[word] = 1;
}
}