src/Foundation/Security/Gimela.Security/RandomGenerator.cs
/// <summary>
/// Generates a random value with giving range of min and max values.
/// </summary>
/// <param name="minValue">The minimum value (including min). The value must be equal or greater than 0</param>
/// <param name="maxValue">The maximum value (including max). The value must be equal or greater than 0 and equal or greater than min value.</param>
/// <returns>The randomly generated value between a given min and max value</returns>
Generates a random value with giving range of min and max values.
Generates a random value with giving range of min and max values .
public static int NextRandomValue(int minValue, int maxValue)
    {
      if (minValue < 0)
      {
        throw new ArgumentOutOfRangeException("minValue", "minValue must be 0 or greater than 0");
      }
      if (maxValue < 0)
      {
        throw new ArgumentOutOfRangeException("maxValue", "maxValue must be 0 or greater than 0");
      }
      if (maxValue < minValue)
      {
        throw new ArgumentOutOfRangeException("maxValue", "max value must be greater than or equal min value");
      }
      Random rnd = new Random();
      int randValue = rnd.Next(minValue, ++maxValue);
      return randValue;
    }
public static int NextRandomValue ( int minValue , int maxValue ) { if ( minValue < 0 ) { throw new ArgumentOutOfRangeException ( " " , " " ) ; } if ( maxValue < 0 ) { throw new ArgumentOutOfRangeException ( " " , " " ) ; } if ( maxValue < minValue ) { throw new ArgumentOutOfRangeException ( " " , " " ) ; } Random rnd = new Random ( ) ; int randValue = rnd . Next ( minValue , ++ maxValue ) ; return randValue ; }
Generates a random value with giving range of min and max values.
Generates a random value with giving range of min and max values .
The randomly generated value between a given min and max value
The randomly generated value between a given min and max value
minValue
int
The minimum value (including min). The value must be equal or greater than 0
The minimum value ( including min ) . The value must be equal or greater than 0
maxValue
int
The maximum value (including max). The value must be equal or greater than 0 and equal or greater than min value.
The maximum value ( including max ) . The value must be equal or greater than 0 and equal or greater than min value .