public static Int32 NextInt32(this Random random, Int32 lowerBound, Int32 upperBound) { lowerBound.ThrowIfGreaterThan(upperBound, nameof(lowerBound)); var value = random.NextInt32() % (upperBound + 1 - lowerBound) + lowerBound; return value; }