title: Multiple random numbers are the same
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/767999/random-number-generator-only-generating-one-random-number">Random number generator only generating one random number</a>  </p>
  </blockquote>
  
  
  
  <p>A beginner question. I have a very simple program that draws a line and I want to randomize the locations, but each time I create a new instance of Random it returns the same value. Where is the problem? Thank you.</p>
  
  <pre><code>private void Draw()
  {
      Random random1 = new Random();
      int randomNumber1 = random1.Next(0, 300);
      Random random2 = new Random();
      int randomNumber2 = random2.Next(0, 300);
      Random random3 = new Random();
      int randomNumber3 = random3.Next(0, 300);
      Random random4 = new Random();
      int randomNumber4 = random4.Next(0, 300);
      System.Drawing.Graphics g = this.CreateGraphics();
      Pen green = new Pen(Color.Green, 5);
      g.DrawLine(green, new Point(randomNumber1, randomNumber2), 
                        new Point(randomNumber3, randomNumber4));
  }
  
  private void btndraw1_Click(object sender, EventArgs e)
  {
      Draw();
  }
  </code></pre>