public bool SentenceContainsWord() { string[] sentenceArray = UserSentence.Split(" "); if (((IList <string>)sentenceArray).Contains(UserWord)) { return(true); } else { return(false); } }
public int RepeatCounter() { int counter = 0; string[] sentenceSplit = UserSentence.Split(' '); foreach (string word in sentenceSplit) { if (word.ToLower() == KeyWord) { counter += 1; } } return(counter); }
public int RepeatCounter(string userWord, string userSentence) { UserWord = userWord.ToLower(); UserSentence = userSentence.ToLower(); string[] sentenceList = UserSentence.Split(" "); int timesAppeared = 0; foreach (string i in sentenceList) { if (i == userWord) { timesAppeared += 1; } else { timesAppeared += 0; } } return(timesAppeared); }