how to randomize questions but still show all the questions?

I managed to randomize my questions. But the problem is, when the last question pops up first, the game seems to end already. Not displaying my other questions.

I assume you grab a random from a list.

When you take the random question, you should remove it from the list.

Then as your end game condition check if the list is empty.

And not have your condition be the last question in the list.

Example:

You will need these references:

using System.Collections.Generic;
using System.Linq;

Script:

private System.Random _random = new System.Random();
public List<int> questionIds = new List<int> { 1, 2, 3, 4, 5 };

public int TakeRandom()
{
    var value = questionIds[_random.Next(questionIds.Count)];
    questionIds.Remove(value);
    return value;
}

public void EndGame()
{
   if (!questionIds.Any())
   {
        // End game
   }
}