KGy SOFT

FastRandom Class

KGy SOFT Core Libraries Help
Represents a pseudo random number generator, which is functionally compatible with the Random class but is significantly faster than that. For cryptographically secure random numbers use the SecureRandom class instead.
Inheritance Hierarchy

SystemObject
  SystemRandom
    KGySoft.CoreLibrariesFastRandom

Namespace:  KGySoft.CoreLibraries
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 6.0.0-rc.2
Syntax

public sealed class FastRandom : Random

The FastRandom type exposes the following members.

Constructors

  NameDescription
Public methodFastRandom
Initializes a new instance of the FastRandom class using a random seed value.
Public methodFastRandom(Guid)
Initializes a new instance of the ThreadSafeRandom class using the specified seed value.
Public methodFastRandom(Int32)
Initializes a new instance of the ThreadSafeRandom class using the specified seed value.
Top
Methods

  NameDescription
Public methodNext
Returns a non-negative random 32-bit integer that is less than Int32.MaxValue.
(Overrides RandomNext.)
Public methodNext(Int32)
Returns a non-negative random 32-bit integer that is less than the specified maximum.
(Overrides RandomNext(Int32).)
Public methodNext(Int32, Int32)
Returns a random 32-bit integer that is within a specified range.
(Overrides RandomNext(Int32, Int32).)
Public methodNextBytes(Byte)
Fills the elements of a specified array of bytes with random numbers.
(Overrides RandomNextBytes(Byte).)
Public methodNextBytes(SpanByte)
Fills the elements of the specified buffer with random numbers.
(Overrides RandomNextBytes(SpanByte).)
Public methodNextDouble
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
(Overrides RandomNextDouble.)
Public methodNextInt32
Returns a non-negative random 32-bit integer that is less than Int32.MaxValue.
Public methodNextInt64
Returns a non-negative random 64-bit integer that is less than Int64.MaxValue.
See the Remarks section for details.
(Overrides Random.NextInt64.)
Public methodNextInt64(Int64)
Returns a non-negative random 64-bit integer that is less than the specified maximum.
(Overrides Random.NextInt64(Int64).)
Public methodNextInt64(Int64, Int64)
Returns a random 64-bit integer that is within a specified range.
(Overrides Random.NextInt64(Int64, Int64).)
Public methodNextSingle
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
(Overrides Random.NextSingle.)
Public methodNextUInt32
Returns a random 32-bit unsigned integer that is less than UInt32.MaxValue.
See the Remarks section for details.
Public methodNextUInt64
Returns a random 64-bit unsigned integer that is less than UInt64.MaxValue.
See the Remarks section for details.
Public methodSampleInt32
Returns a random Int32 can have any value.
See the Remarks section for details.
Public methodSampleInt64
Returns a random Int64 can have any value.
See the Remarks section for details.
Top
Extension Methods

  NameDescription
Public Extension MethodConvert(Type, CultureInfo)Overloaded.
Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions.)
Public Extension MethodCode exampleConvertTTarget(CultureInfo)Overloaded.
Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions.)
Public Extension MethodIn (Defined by ObjectExtensions.)
Public Extension MethodNextBoolean
Returns a random Boolean value.
(Defined by RandomExtensions.)
Public Extension MethodNextByteOverloaded.
Returns a random 8-bit unsigned integer that is less than Byte.MaxValue. To return any Byte use the SampleByte method instead.
(Defined by RandomExtensions.)
Public Extension MethodNextByte(Byte, Boolean)Overloaded.
Returns a random 8-bit unsigned integer that is within the specified maximum.
(Defined by RandomExtensions.)
Public Extension MethodNextByte(Byte, Byte, Boolean)Overloaded.
Returns a random 8-bit unsigned integer that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextBytes
Returns an Array of random bytes that has the specified length.
(Defined by RandomExtensions.)
Public Extension MethodNextChar
Returns a random Char value that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(Int32, String)Overloaded.
Returns an Array of random characters that has the specified length.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(Int32, Char)Overloaded.
Returns an Array of random characters that has the specified length.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(Int32, ReadOnlySpanChar)Overloaded.
Returns an Array of random characters that has the specified length.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(Int32, StringCreation)Overloaded.
Returns an Array of random characters using the specified strategy that has the specified length.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(Char, String)Overloaded.
Fills the elements of a buffer of character array with random characters using the specified allowedCharacters.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(Char, Char)Overloaded.
Fills the elements of a buffer of character array with random characters using the specified allowedCharacters.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(Char, StringCreation)Overloaded.
Fills the elements of a buffer of character array with random characters using the specified strategy.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(SpanChar, ReadOnlySpanChar)Overloaded.
Fills the elements of a buffer with random characters using the specified allowedCharacters.
(Defined by RandomExtensions.)
Public Extension MethodNextChars(SpanChar, StringCreation)Overloaded.
Fills the elements of a buffer with random characters using the specified strategy.
(Defined by RandomExtensions.)
Public Extension MethodNextDate
Returns a random DateTime that is between the specified range and has only date component.
(Defined by RandomExtensions.)
Public Extension MethodNextDateTime
Returns a random DateTime that is between the specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextDateTimeOffset
Returns a random DateTimeOffset that is between the specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextDecimalOverloaded.
Returns a random Decimal value that is greater than or equal to 0.0 and less than 1.0.
(Defined by RandomExtensions.)
Public Extension MethodNextDecimal(Decimal, FloatScale)Overloaded.
Returns a non-negative random Decimal value that is less or equal to the specified maxValue.
See the Remarks section for details.
(Defined by RandomExtensions.)
Public Extension MethodNextDecimal(Decimal, Decimal, FloatScale)Overloaded.
Returns a random Decimal value that is within a specified range.
See the Remarks section for details.
(Defined by RandomExtensions.)
Public Extension MethodNextDouble(Double, FloatScale)Overloaded.
Returns a non-negative random Double value that is less or equal to the specified maxValue.
See the Remarks section for details.
(Defined by RandomExtensions.)
Public Extension MethodNextDouble(Double, Double, FloatScale)Overloaded.
Returns a random Double value that is within a specified range.
See the Remarks section for details.
(Defined by RandomExtensions.)
Public Extension MethodNextEnumTEnum
Returns a random TEnum value.
(Defined by RandomExtensions.)
Public Extension MethodNextGuid
Returns a random RFC 4122 compliant Guid value generated by using the specified Random instance.
(Defined by RandomExtensions.)
Public Extension MethodNextInt16Overloaded.
Returns a non-negative random 16-bit signed integer that is less than Int16.MaxValue. To return any Int16 use the SampleInt16 method instead.
(Defined by RandomExtensions.)
Public Extension MethodNextInt16(Int16, Boolean)Overloaded.
Returns a non-negative random 16-bit signed integer that is within the specified maximum.
(Defined by RandomExtensions.)
Public Extension MethodNextInt16(Int16, Int16, Boolean)Overloaded.
Returns a random 16-bit signed integer that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextInt32Overloaded.
Returns a non-negative random 32-bit signed integer that is less than Int32.MaxValue. To return any Int32 use the SampleInt32 method instead.
(Defined by RandomExtensions.)
Public Extension MethodNextInt32(Int32, Boolean)Overloaded.
Returns a non-negative random 32-bit signed integer that is within the specified maximum.
(Defined by RandomExtensions.)
Public Extension MethodNextInt32(Int32, Int32, Boolean)Overloaded.
Returns a random 32-bit signed integer that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextInt64Overloaded.
Returns a non-negative random 64-bit signed integer that is less than Int64.MaxValue. To return any Int64 use the SampleInt64 method instead.
(Defined by RandomExtensions.)
Public Extension MethodNextInt64(Int64, Boolean)Overloaded.
Returns a non-negative random 64-bit signed integer that is within the specified maximum.
(Defined by RandomExtensions.)
Public Extension MethodNextInt64(Int64, Int64, Boolean)Overloaded.
Returns a random Int64 value that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextObject(Type, GenerateObjectSettings)Overloaded.
Returns a random object of the specified type or   if type cannot be instantiated with the provided settings.
(Defined by RandomExtensions.)
Public Extension MethodNextObjectT(GenerateObjectSettings)Overloaded.
Returns a random object of type T or the default value of T if T cannot be instantiated with the provided settings.
See the Remarks section for details.
(Defined by RandomExtensions.)
Public Extension MethodNextSByteOverloaded.
Returns a non-negative random 8-bit signed integer that is less than SByte.MaxValue. To return any SByte use the SampleSByte method instead.
(Defined by RandomExtensions.)
Public Extension MethodNextSByte(SByte, Boolean)Overloaded.
Returns a non-negative random 8-bit signed integer that is within the specified maximum.
(Defined by RandomExtensions.)
Public Extension MethodNextSByte(SByte, SByte, Boolean)Overloaded.
Returns a random 8-bit signed integer that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextSingleOverloaded.
Returns a random Single value that is greater than or equal to 0.0 and less than 1.0.
(Defined by RandomExtensions.)
Public Extension MethodNextSingle(Single, FloatScale)Overloaded.
Returns a non-negative random Single value that is less or equal to the specified maxValue.
See the Remarks section for details.
(Defined by RandomExtensions.)
Public Extension MethodNextSingle(Single, Single, FloatScale)Overloaded.
Returns a random Single value that is within a specified range.
See the Remarks section for details.
(Defined by RandomExtensions.)
Public Extension MethodNextString(StringCreation)Overloaded.
Returns a random String using the specified strategy that has the length between 4 and 10 inclusive.
(Defined by RandomExtensions.)
Public Extension MethodNextString(Int32, StringCreation)Overloaded.
Returns a random String of the specified length using the specified strategy that has the length between the specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextString(Int32, Int32, String)Overloaded.
Returns a random String that has the length between the specified range and consists of the specified allowedCharacters.
(Defined by RandomExtensions.)
Public Extension MethodNextString(Int32, Int32, Char)Overloaded.
Returns a random String that has the length between the specified range and consists of the specified allowedCharacters.
(Defined by RandomExtensions.)
Public Extension MethodNextString(Int32, Int32, ReadOnlySpanChar)Overloaded.
Returns a random String that has the length between the specified range and consists of the specified allowedCharacters.
(Defined by RandomExtensions.)
Public Extension MethodNextString(Int32, Int32, StringCreation)Overloaded.
Returns a random String using the specified strategy that has the length between the specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextTimeSpan
Returns a random TimeSpan that is between the specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt16Overloaded.
Returns a random 16-bit unsigned integer that is less than UInt16.MaxValue. To return any UInt16 use the SampleUInt16 method instead.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt16(UInt16, Boolean)Overloaded.
Returns a random 16-bit unsigned integer that is within the specified maximum.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt16(UInt16, UInt16, Boolean)Overloaded.
Returns a random 16-bit unsigned integer that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt32Overloaded.
Returns a random 32-bit unsigned integer that is less than UInt32.MaxValue. To return any UInt32 use the SampleUInt32 method instead.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt32(UInt32, Boolean)Overloaded.
Returns a random 32-bit unsigned integer that is within the specified maximum.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt32(UInt32, UInt32, Boolean)Overloaded.
Returns a random 32-bit unsigned integer that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt64Overloaded.
Returns a random 64-bit unsigned integer that is less than UInt64.MaxValue. To return any UInt64 use the SampleUInt64 method instead.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt64(UInt64, Boolean)Overloaded.
Returns a random 64-bit unsigned integer that is within the specified maximum.
(Defined by RandomExtensions.)
Public Extension MethodNextUInt64(UInt64, UInt64, Boolean)Overloaded.
Returns a random 64-bit unsigned integer that is within a specified range.
(Defined by RandomExtensions.)
Public Extension MethodSampleByte
Returns a random Byte that can have any value.
(Defined by RandomExtensions.)
Public Extension MethodSampleInt16
Returns a random Int16 that can have any value.
(Defined by RandomExtensions.)
Public Extension MethodSampleInt32
Returns a random Int32 that can have any value.
(Defined by RandomExtensions.)
Public Extension MethodSampleInt64
Returns a random Int64 that can have any value.
(Defined by RandomExtensions.)
Public Extension MethodSampleSByte
Returns a random SByte that can have any value.
(Defined by RandomExtensions.)
Public Extension MethodSampleUInt16
Returns a random UInt16 that can have any value.
(Defined by RandomExtensions.)
Public Extension MethodSampleUInt32
Returns a random UInt32 that can have any value.
(Defined by RandomExtensions.)
Public Extension MethodSampleUInt64
Returns a random UInt64 that can have any value.
(Defined by RandomExtensions.)
Public Extension MethodTryConvert(Type, Object)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvert(Type, CultureInfo, Object)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvertTTarget(TTarget)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvertTTarget(CultureInfo, TTarget)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions.)
Top
See Also

Reference