public void Assignment3() { Console.WriteLine("Assignment 3: No. of distinct words in string"); DistinctWords dWordObj = new DistinctWords(); dWordObj.CountNumberOfDistinctWords(); }
} //End Method /// <summary> /// Tests to see whether the word should be added to an existing word's count or added to the list /// </summary> /// <param name="tempWord">The word to be added</param> private void AddWordOrCount(DistinctWord tempWord) { //if it is a word it checks to see if it is already in the list and adds it to the respective words count if (!DistinctWords.Contains(tempWord)) { DistinctWords.Add(tempWord); } else { foreach (var word in DistinctWords) { word.Count += (word.Word == tempWord.Word) ? 1 : 0; } //End Foreach } //End If }