C# Get random items or numbers

Date: 2021-11-19
private static readonly Random RandomGenerator = new Random();

static T GetRandom<T>(params T[] values)
{
	return values[RandomGenerator.Next(values.Length)];
}
static int GetRandomNumber(int minimum, int maximum)
{
	return RandomGenerator.Next(minimum, maximum);
}
static double GetRandomNumber(double minimum, double maximum)
{
	return RandomGenerator.NextDouble() * (maximum - minimum) + minimum;
}

// 0 .. 24
GetRandomNumber(0, 24)

// 1000 || 2000 || 4000
GetRandom(1000, 2000, 4000)

// true || false
GetRandom(true, false) 
56580cookie-checkC# Get random items or numbers