title: C# Can I identify what Random selects between the range?
body: <p>I want to be able to determine what the value is selected when I get a random number in windows forms. 
  For example, <strong>int mynum = numbers[rand.Next(0,7)];</strong>
  I know the range is between 0 and 7, but I want to be able to identify what number is selected. e.g. numbers[3]</p>
  
  <p>The following is the code I have.  I have read binary values into an array int [] numbers and passed it through the following method.  It generates my random 3 bit binary value, but I am making a small quiz where the number identified is the value the random number selects (e.g. the location 3 is the correct value for the item stored there, numbers[i] ==answer).  </p>
  
  <p>Is there a way to access this value?</p>
  
  <pre><code>public void generateBinary3bit(int[] numbers, Form1 f1)
          {
              Random rand = new Random();
              int mynum = numbers[rand.Next(0,7)];
  
              **int ans = numbers[rand];** 
  
              f1.lblBinaryText.Text = mynum.ToString();
          }
  </code></pre>
  
  <p>For context, I am reading in the values into the array here:</p>
  
  <pre><code>int [] numbers = new int[8];
  
    public void readNumbers(int[]numbers, Form1 F1)
          {
              try
              {
                  StreamReader sr = new StreamReader(@"C:\BinaryNumbers.csv");
  
                  while(sr.ReadLine() !=null)
                  {
                      for (int i = 0; i &lt; numbers.Length; i++)
                      {
                          numbers[i] = Convert.ToInt32(sr.ReadLine());
                          answer = i;
                      }
                  }
                  sr.Close();
              }
              catch ( Exception e)
              {
              }
          }
  </code></pre>
  
  <p>Thank you,</p>