temprand = rand.Next(quiztemp.totalQuestions()); while(questions.Exists(ContainsRand)) { temprand = rand.Next(quiztemp.totalQuestions()); } questions.Add(temprand); private bool ContainsRand(int i) { if (i == temprand) { return true; } else { return false; } }