title: Non-repetitive random number in asp.net C#
body: <p>I have 6 question in 6 asp.net panel server control ,
  I need to show them all panel one by one in random order( one question is visible and other invisible every time ).</p>
  
  <p>I don't know how to exclude the number from generating again . 
  I write like this : </p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  Random rnd = new Random();
                  int startNumber = rnd.Next(1, 6);
                  ShowNextPanel(startNumber);
              }
          }
  
      private void ShowNextPanel(int excludeNumber)
      {
          Random rnd = new Random();
          //I need to exclude the "excludeNumber" here but I don't know how !?
          int number = rnd.Next(1, 6);
          switch (number)
          {
              case 1:
                  {
                      Panel1.Visible = true;
                      break;
                  }
              case 2:
                  {
                      Panel2.Visible = true;
                      break;
                  }
              case 3:
                  {
                      Panel3.Visible = true;
                      break;
                  }
              case 4:
                  {
                      Panel4.Visible = true;
                      break;
                  }
              case 5:
                  {
                      Panel5.Visible = true;
                      break;
                  }
              case 6:
                  {
                      Panel6.Visible = true;
                      break;
                  }
          }
  
      }
      protected void Button1_Click(object sender, EventArgs e)
      {
         // InsertToDB(1, DropDownList1.SelectedValue);
          Panel1.Visible = false;
          ShowNextPanel(1);
  
      }
      protected void Button2_Click(object sender, EventArgs e)
      {
         // InsertToDB(2, DropDownList2.SelectedValue);
          Panel2.Visible = false;
          ShowNextPanel(2);
  
      }
  //and go on till button6_click
  </code></pre>