I am writing a simple quiz on C #: there are 4 buttons on one panel, you need to place answer options on them. Naturally, the correct one should not constantly hit the same button.

How to make the placement of answers random? What are the alternatives?

    1 answer 1

    The most obvious solution is to sort the array of responses in random order:

    // Исходная последовательность ответов int[] answers = { 1, 2, 3, 4 }; // Объект генератора случайных чисел Random rnd = new Random(); // Случайная последовательность ответов answers = answers.OrderBy(item => rnd.Next()).ToArray(); 

    After that, you can consistently load each of them onto the corresponding interface elements: the original order of answers is already broken by random sorting.

    PS In your case, however, it should be more complex objects that store information about whether a particular answer is correct or not.