Search Results for

    Show / Hide Table of Contents

    Class Random

    Represents a pseudo-random number generator, based on the sourcecode of System.Random. This implementation identifies- and deals with some multithreading concurrency problems.

    Inheritance
    System.Object
    Random
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: ImageVault.Common.Lib
    Assembly: ImageVault.Common.dll
    Syntax
    public class Random

    Constructors

    Random()

    Initializes a new instance of the Random class, using a time-dependent default seed value.

    Declaration
    public Random()

    Random(Int32)

    Initializes a new instance of the Random class, using the specified seed value.

    Declaration
    public Random(int seed)
    Parameters
    Type Name Description
    System.Int32 seed

    A number used to calculate a starting value for the pseudo-random number sequence. If a negative number is specified, the absolute value of the number is used.

    Methods

    Next()

    Returns a non-negative random integer.

    Declaration
    public virtual int Next()
    Returns
    Type Description
    System.Int32

    A 32-bit signed integer that is greater than or equal to 0 and less than System.Int32.MaxValue.

    Next(Int32)

    Returns a non-negative random integer that is less than the specified maximum.

    Declaration
    public virtual int Next(int maxValue)
    Parameters
    Type Name Description
    System.Int32 maxValue

    The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0.

    Returns
    Type Description
    System.Int32

    A 32-bit signed integer that is greater than or equal to 0, and less than maxValue; that is, the range of return values ordinarily includes 0 but not maxValue. However, if maxValue equals 0, maxValue is returned.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    maxValue is less than 0.

    Next(Int32, Int32)

    Returns a random integer that is within a specified range.

    Declaration
    public virtual int Next(int minValue, int maxValue)
    Parameters
    Type Name Description
    System.Int32 minValue

    The inclusive lower bound of the random number returned.

    System.Int32 maxValue

    The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue.

    Returns
    Type Description
    System.Int32

    A 32-bit signed integer greater than or equal to minValue and less than maxValue; that is, the range of return values includes minValue but not maxValue. If minValue equals maxValue, minValue is returned.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    minValue is greater than maxValue.

    NextBytes(Byte[])

    Fills the elements of a specified array of bytes with random numbers.

    Declaration
    public virtual void NextBytes(byte[] buffer)
    Parameters
    Type Name Description
    System.Byte[] buffer

    An array of bytes to contain random numbers.

    Exceptions
    Type Condition
    System.ArgumentNullException

    buffer is null.

    NextDouble()

    Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.

    Declaration
    public virtual double NextDouble()
    Returns
    Type Description
    System.Double

    A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.

    Sample()

    Returns a random floating-point number between 0.0 and 1.0.

    Declaration
    protected virtual double Sample()
    Returns
    Type Description
    System.Double

    A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.

    Extension Methods

    EnumExtensions.GetNames<TEnum>(TEnum)
    In This Article
    Back to top (c) Meriworks 2002-2022