title: Adding a fresh (new) instance of an object to a list
body: <p>This is a very similar problem to here <a href="https://stackoverflow.com/questions/5717517/c-sharp-creating-new-instances-of-a-object-in-a-for-loop">c# creating new instances of a object in a for loop</a> but my problem is unfortunately slightly different. I'm not using random either.</p>
  
  <p>I have a setup similar to this:</p>
  
  <pre><code>public List&lt;Candle&gt; GetCandles(int can)
  {
      List&lt;Candle&gt; dpl = new List&lt;Candle&gt;();
  
      for (int i = 0; i &lt; can; i++)
      {
          Candle dp = new Candle();
          dp.x = new Random().Next(0000, 9999);
          dp.y = new Random().Next(0000, 9999);
          dpl.Add(dp);
      }
  
      return dpl;
  }
  </code></pre>
  
  <p>My problem is that at the end of it, I don't have separate instances of candles inside. They're all the same candle for each element - despite me using "new" each time.</p>
  
  <p>How do I make 100% sure that I'm putting a brand new candle into the list?</p>
  
  <p>EDIT: Thanks to all that answered, but I was able to find out my own problem. Inside the class I was using, the variables were <strong>static</strong>. That meant that every single class instance had the same value. So if I set A to equal 50, all of the classes had 50.</p>
  
  <p>I'm sorry if it wasn't clear, but that code wasn't mine. I'm not using random, I just posted the example because it was similar to the setup I had in my code. I had a loop and a list and was adding instances to it.</p>