I added some string into list from database , i random the string order and display it but i don't want the random string to appear again , so i did a remove(string) however it won't work .
So i declared a list string like this :
 List<string> questionNo = new List<string>();
This is the code i put in on PageLoad( outside of !Page.IsPostBack) :
  protected void RandomMCQ1()
{
    Random r = new Random();
    int index = r.Next(questionNo.Count());
    randomString = questionNo[index];   // Random a string from list ( I declare randomString as a string in global)
    questionNo.Remove(randomString);    // Then remove it
}
So i want to test it by displaying randomString after a button clicking like this :
  protected void btnNext_Click(object sender, EventArgs e)
    {
        Response.Write(questionNo.Count); // Display list<string> count
        Response.Write(randomString); // Display the random string .
    }
I have 2 values in the list : 10 and 11
so the count of the list is 2 The count is correct when i click the button ( the count suppose to be 2 , after i click the button , it reduces to 1 ) but the random string can display 10 or 11 , shouldn't it be when i click the button the first time , it display either 10 or 11 , if it displays 10 , the second i click the button it should display 11 then the 3rd time i press it should not display anything .
---EDIT-----
This is how i get my list ( this code is in PageLoad outside of !Page.IsPostBack)
 protected void PopulateMCQ()
{
    string query = "...";
    conn.Open();
    SqlCommand cmd = new SqlCommand(query, conn);
    SqlDataReader dr;
    dr = cmd.ExecuteReader();
    while (dr.Read())
    {
        Label questionID = new Label();
        questionID.Text = dr["englishID"].ToString();
        questionNo.Add(questionID.Text); // I add the values to the list<string> here
    }
    conn.Close();
}
 
     
     
    