Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Questions about the Random Class

$
0
0

So I'm wondering about the Random class and why Microsoft decided to create it the way they did. When looking at it, my initial thought was that each method called from the instance created a new seed from the time to generate and new number, but that does not seem to be the case. Then I figured it is possible to set a new seed at run time, but I could not, at least not that I know of. Finally I wonder why most of Random's method are not just static and create a new seed as you call it. So, can someone knowledgeable explain why this format is the best or why it's just the way it is?

Also following that question, earlier I created a public Random class and when I used it to generate large numbers it worked well, but generating those in double (especially single) digits, the output was biased. I'm sure it's a part of the algorithm on top of using the same instance class, but I would like to be corrected if I am wrong.

Now I am wondering if it is efficient is some cases to create a public static method to call whenever, each time creating a new instance of Random and using it accordingly.

Thanks.



Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>