-
Notifications
You must be signed in to change notification settings - Fork 0
Random.Rng
NotCoffee418 edited this page Oct 30, 2021
·
2 revisions
The Rng class provives an simplified interface to the .NET's System.Security.Cryptography.System.Security.Cryptography.
This class allows you to easily generate randoms of various types.
Defining a range is currently only possible for int. Other types will generate any valid value.
using CoffeeToolkit.Random;
void GenerateRandoms() {
bool randomBool = Rng.Bool();
ushort randomUshort = Rng.UInt16();
short randomShort = Rng.Int16();
uint randomUint = Rng.UInt32();
int randomInt = Rng.Int32();
ulong randomUlong = Rng.UInt64();
long randomLong = Rng.Int64();
float randomFloat = Rng.Single();
double randomDouble = Rng.Double();
byte randomByte = Rng.Byte();
byte[] randomByteArray = Rng.ByteArray(8);
// Int with range
int randomWithRange = Rng.Generate(1, 100);
}