Correct method of a “static” Random.Next in C#?

It is best practice to create a single instance of Random and use it throughout your program – otherwise the results may not be as random. This behavior is encouraged by not creating a static function.

You shouldn’t worry about “creating an instance unnecessarily”, the impact is negligible at best – this is the way the framework works.

Leave a Comment