private void fillWindow() { currentQuestions = dictionary.GetNext(); btn_Answer_1.Content = currentQuestions.answers[0]; btn_Answer_2.Content = currentQuestions.answers[1]; btn_Answer_3.Content = currentQuestions.answers[2]; btn_Answer_4.Content = currentQuestions.answers[3]; txbl_Question.Text = currentQuestions.question; }
public CurrentQuestions GetNext() { Random rand = new Random(); CurrentQuestions currentQuestions = new CurrentQuestions(); currentQuestions.answers = new string[4]; currentQuestions.question = dictionary.ElementAt(rand.Next(0, dictionary.Count)).Key; currentQuestions.correctID = rand.Next(0, 3); dictionary.TryGetValue(currentQuestions.question, out currentQuestions.answers[currentQuestions.correctID]); for (int i = 0; i < currentQuestions.answers.Length; i++) { if (currentQuestions.answers[i] == null) { currentQuestions.answers[i] = dictionary.ElementAt(rand.Next(0, dictionary.Count)).Value; } } return(currentQuestions); }