Class RandomExtensions
- Namespace
- Plugin.BaseTypeExtensions
- Assembly
- Plugin.BaseTypeExtensions.dll
Provides extension methods for the Random class.
public static class RandomExtensions
- Inheritance
-
RandomExtensions
- Inherited Members
Methods
NextBool(Random, int, int)
Returns true with a probability of chances
out of outOf
.
public static bool NextBool(this Random random, int chances, int outOf)
Parameters
random
RandomThe random number generator.
chances
intThe number of chances for true.
outOf
intThe total number of possible outcomes.
Returns
- bool
True with the specified probability; otherwise, false.
NextByte(Random)
Returns a random byte value between 0 and 254.
public static byte NextByte(this Random random)
Parameters
random
RandomThe random number generator.
Returns
- byte
A random byte value.
NextDouble(Random, double, double)
Returns a random double value between min
(inclusive) and max
(exclusive).
public static double NextDouble(this Random random, double min = 0, double max = 1)
Parameters
random
RandomThe random number generator.
min
doubleThe inclusive lower bound.
max
doubleThe exclusive upper bound.
Returns
- double
A random double value in the specified range.