MarkovText.Markov.getRandomWord C# (CSharp) Method

getRandomWord() private method

private getRandomWord ( ) : string
return string
        private string getRandomWord()
        {
            string toReturn;
            //The first case should only possibly occur when looking at the very last word of input.
            while (!wordGroups.ContainsKey(getCurKey()))
            {
                initKeys();
            }
            List<string> possible = wordGroups[getCurKey()];
            int i = random.Next(0, possible.Count);
            toReturn = possible[i];
            moveNextKey(toReturn);
            return toReturn;
        }