CheckWordIsValid

From TRCCompSci - AQA Computer Science
Revision as of 13:37, 14 November 2017 by Max (talk | contribs)
Jump to: navigation, search
        private static bool CheckWordIsValid(string Word, List<string> AllowedWords)
        {
            bool ValidWord = false;
            int Count = 0;
            while (Count < AllowedWords.Count && !ValidWord)
            {
                if (AllowedWords[Count] == Word)
                {
                    ValidWord = true;
                }
                Count++;
            }
            return ValidWord;
        }

The code starts by setting the variable ValidWord to false and the variable to the integer value of 0. The next line says while the count is less than the total number of allowed words &