Does every CPU return the same random sequence based on the same seed if my application targets .NET framework 3.5? I am checking if you get the same result as me. I am also hoping that everyone who I distribute my application to will get the same result. Thanks!
Random a = new Random(44448);
int i1 = a.Next(65, 90);
MessageBox.Show(i1.ToString());
For a specific framework version your program should give the same result each time you run it, because of the fixed seed.
But it can give different results on different versions of the .NET framework.
For example, on .NET 4.0 I get
77
. But putting the code into ideone (which uses Mono) gives67
.The reason for this difference is because the precise algorithm used by
Random
is not part of the specification. The documentation has this information about the algorithm:Emphasis mine. There are no guarantees that future implementations will use the same algorithm.