Skip to content

A default-constructed instance of the System.Random class. A part of the C# Language Syntactic Sugar suite.

License

Notifications You must be signed in to change notification settings

tonygiang/CLSS.Constants.DefaultRandom

Repository files navigation

CLSS.Constants.DefaultRandom

Problem

System.Random requires a class instance to be used. Constructing a new instance each time you need a random number generator will allocate some memory for that instance. This incurs an allocation cost and a runtime garbage collection cost. .NET developers seemingly have realized this is an issue and added System.Random.Shared in .NET 6, but for many projects still bound to an earlier version of .NET, this shared Random instance is not available.

Solution

Once you install this package, you can access a global, persisting System.Random instance with CLSS.DefaultRandom.Instance.

This package is a part of the C# Language Syntactic Sugar suite.

About

A default-constructed instance of the System.Random class. A part of the C# Language Syntactic Sugar suite.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages