System.Random not so random, why does this occur?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/767999/random-number-generator-only-generating-one-random-number">Random number generator only generating one random number</a>  </p>
</blockquote>



<p>I've distilled the behavior observed in a larger system into this code sequence:</p>

<pre><code>for (int i = 0; i &lt; 100; i++)
{
    Random globalRand = new Random(0x3039 + i);

    globalRand.Next();
    globalRand.Next();
    int newSeed = globalRand.Next();

    Random rand = new Random(newSeed);
    int value = rand.Next(1, 511);
    Console.WriteLine(value);
}
</code></pre>

<p>Running this from Visual Studio 2012 targeting .NET 4.5 will output either 316 or 315.  Extending this beyond 100 iterations and you'll see the value slowly decrement (314, 313...) but it still isn't what I'd imagine anyone would consider "random".</p>

<p><strong>EDIT</strong></p>

<p>I am aware that there are several questions on StackOverflow already that ask why their random numbers aren't random.  However, those questions have issues regarding one of a) not passing in a seed (or passing in the same seed) to their Random object instance or b) doing something like <code>NextInt(0, 1)</code> and not realizing that the second parameter is an exclusive bound.  Neither of those issues are true for this question.</p>
