示例#1
0
 public bool SentenceContainsWord()
 {
     string[] sentenceArray = UserSentence.Split(" ");
     if (((IList <string>)sentenceArray).Contains(UserWord))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
        public int RepeatCounter()
        {
            int counter = 0;

            string[] sentenceSplit = UserSentence.Split(' ');
            foreach (string word in sentenceSplit)
            {
                if (word.ToLower() == KeyWord)
                {
                    counter += 1;
                }
            }
            return(counter);
        }
示例#3
0
        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);
        }