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
SystemRandom
KGySoft.CoreLibrariesFastRandom
Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 6.0.0rc.1
Syntax
The FastRandom type exposes the following members.
Constructors
Name  Description  

FastRandom 
Initializes a new instance of the FastRandom class using a random seed value.
 
FastRandom(Guid) 
Initializes a new instance of the ThreadSafeRandom class using the specified seed value.
 
FastRandom(Int32) 
Initializes a new instance of the ThreadSafeRandom class using the specified seed value.

Methods
Name  Description  

Next 
Returns a nonnegative random 32bit integer that is less than Int32.MaxValue.
(Overrides RandomNext.)  
Next(Int32) 
Returns a nonnegative random 32bit integer that is less than the specified maximum.
(Overrides RandomNext(Int32).)  
Next(Int32, Int32) 
Returns a random 32bit integer that is within a specified range.
(Overrides RandomNext(Int32, Int32).)  
NextBytes(Byte) 
Fills the elements of a specified array of bytes with random numbers.
(Overrides RandomNextBytes(Byte).)  
NextBytes(SpanByte) 
Fills the elements of the specified buffer with random numbers.
(Overrides RandomNextBytes(SpanByte).)  
NextDouble 
Returns a random floatingpoint number that is greater than or equal to 0.0, and less than 1.0.
(Overrides RandomNextDouble.)  
NextInt32 
Returns a nonnegative random 32bit integer that is less than Int32.MaxValue.
 
NextInt64 
Returns a nonnegative random 64bit integer that is less than Int64.MaxValue.
(Overrides Random.NextInt64.)See the Remarks section for details.  
NextInt64(Int64) 
Returns a nonnegative random 64bit integer that is less than the specified maximum.
(Overrides Random.NextInt64(Int64).)  
NextInt64(Int64, Int64) 
Returns a random 64bit integer that is within a specified range.
(Overrides Random.NextInt64(Int64, Int64).)  
NextSingle 
Returns a random floatingpoint number that is greater than or equal to 0.0, and less than 1.0.
(Overrides Random.NextSingle.)  
NextUInt32 
Returns a random 32bit unsigned integer that is less than UInt32.MaxValue.
See the Remarks section for details.  
NextUInt64 
Returns a random 64bit unsigned integer that is less than UInt64.MaxValue.
See the Remarks section for details.  
SampleInt32 
Returns a random Int32 can have any value.
See the Remarks section for details.  
SampleInt64 
Returns a random Int64 can have any value.
See the Remarks section for details. 
Extension Methods
Name  Description  

Convert(Type, CultureInfo)  Overloaded.
Converts an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.  
ConvertTTarget(CultureInfo)  Overloaded. (Defined by ObjectExtensions.)  
In 
Gets whether item is among the elements of set.
(Defined by ObjectExtensions.)See the Examples section of the generic InT(T, T) overload for an example.  
NextBoolean 
Returns a random Boolean value.
(Defined by RandomExtensions.)  
NextByte  Overloaded.
Returns a random 8bit unsigned integer that is less than Byte.MaxValue.
To return any Byte use the SampleByte method instead.
(Defined by RandomExtensions.)  
NextByte(Byte, Boolean)  Overloaded.
Returns a random 8bit unsigned integer that is within the specified maximum.
(Defined by RandomExtensions.)  
NextByte(Byte, Byte, Boolean)  Overloaded.
Returns a random 8bit unsigned integer that is within a specified range.
(Defined by RandomExtensions.)  
NextBytes 
Returns an Array of random bytes that has the specified length.
(Defined by RandomExtensions.)  
NextChar 
Returns a random Char value that is within a specified range.
(Defined by RandomExtensions.)  
NextChars(Int32, String)  Overloaded.
Returns an Array of random characters that has the specified length.
(Defined by RandomExtensions.)  
NextChars(Int32, Char)  Overloaded.
Returns an Array of random characters that has the specified length.
(Defined by RandomExtensions.)  
NextChars(Int32, ReadOnlySpanChar)  Overloaded.
Returns an Array of random characters that has the specified length.
(Defined by RandomExtensions.)  
NextChars(Int32, StringCreation)  Overloaded. (Defined by RandomExtensions.)  
NextChars(Char, String)  Overloaded.
Fills the elements of a buffer of character array with random characters using the specified allowedCharacters.
(Defined by RandomExtensions.)  
NextChars(Char, Char)  Overloaded.
Fills the elements of a buffer of character array with random characters using the specified allowedCharacters.
(Defined by RandomExtensions.)  
NextChars(Char, StringCreation)  Overloaded.
Fills the elements of a buffer of character array with random characters using the specified strategy.
(Defined by RandomExtensions.)  
NextChars(SpanChar, ReadOnlySpanChar)  Overloaded.
Fills the elements of a buffer with random characters using the specified allowedCharacters.
(Defined by RandomExtensions.)  
NextChars(SpanChar, StringCreation)  Overloaded.
Fills the elements of a buffer with random characters using the specified strategy.
(Defined by RandomExtensions.)  
NextDate 
Returns a random DateTime that is between the specified range and has only date component.
(Defined by RandomExtensions.)  
NextDateTime 
Returns a random DateTime that is between the specified range.
(Defined by RandomExtensions.)  
NextDateTimeOffset 
Returns a random DateTimeOffset that is between the specified range.
(Defined by RandomExtensions.)  
NextDecimal  Overloaded.
Returns a random Decimal value that is greater than or equal to 0.0 and less than 1.0.
(Defined by RandomExtensions.)  
NextDecimal(Decimal, FloatScale)  Overloaded.
Returns a nonnegative random Decimal value that is less or equal to the specified maxValue.
(Defined by RandomExtensions.)See the Remarks section for details.  
NextDecimal(Decimal, Decimal, FloatScale)  Overloaded.
Returns a random Decimal value that is within a specified range.
(Defined by RandomExtensions.)See the Remarks section for details.  
NextDouble(Double, FloatScale)  Overloaded.
Returns a nonnegative random Double value that is less or equal to the specified maxValue.
(Defined by RandomExtensions.)See the Remarks section for details.  
NextDouble(Double, Double, FloatScale)  Overloaded.
Returns a random Double value that is within a specified range.
(Defined by RandomExtensions.)See the Remarks section for details.  
NextEnumTEnum 
Returns a random TEnum value.
(Defined by RandomExtensions.)  
NextGuid  (Defined by RandomExtensions.)  
NextInt16  Overloaded.
Returns a nonnegative random 16bit signed integer that is less than Int16.MaxValue.
To return any Int16 use the SampleInt16 method instead.
(Defined by RandomExtensions.)  
NextInt16(Int16, Boolean)  Overloaded.
Returns a nonnegative random 16bit signed integer that is within the specified maximum.
(Defined by RandomExtensions.)  
NextInt16(Int16, Int16, Boolean)  Overloaded.
Returns a random 16bit signed integer that is within a specified range.
(Defined by RandomExtensions.)  
NextInt32  Overloaded.
Returns a nonnegative random 32bit signed integer that is less than Int32.MaxValue.
To return any Int32 use the SampleInt32 method instead.
(Defined by RandomExtensions.)  
NextInt32(Int32, Boolean)  Overloaded.
Returns a nonnegative random 32bit signed integer that is within the specified maximum.
(Defined by RandomExtensions.)  
NextInt32(Int32, Int32, Boolean)  Overloaded.
Returns a random 32bit signed integer that is within a specified range.
(Defined by RandomExtensions.)  
NextInt64  Overloaded.
Returns a nonnegative random 64bit signed integer that is less than Int64.MaxValue.
To return any Int64 use the SampleInt64 method instead.
(Defined by RandomExtensions.)  
NextInt64(Int64, Boolean)  Overloaded.
Returns a nonnegative random 64bit signed integer that is within the specified maximum.
(Defined by RandomExtensions.)  
NextInt64(Int64, Int64, Boolean)  Overloaded.
Returns a random Int64 value that is within a specified range.
(Defined by RandomExtensions.)  
NextObject(Type, GenerateObjectSettings)  Overloaded.
Returns a random object of the specified type or
if type cannot be instantiated with the provided settings.
(Defined by RandomExtensions.)  
NextObjectT(GenerateObjectSettings)  Overloaded.
Returns a random object of type T or the default value of T
if T cannot be instantiated with the provided settings.
(Defined by RandomExtensions.)See the Remarks section for details.  
NextSByte  Overloaded.
Returns a nonnegative random 8bit signed integer that is less than SByte.MaxValue.
To return any SByte use the SampleSByte method instead.
(Defined by RandomExtensions.)  
NextSByte(SByte, Boolean)  Overloaded.
Returns a nonnegative random 8bit signed integer that is within the specified maximum.
(Defined by RandomExtensions.)  
NextSByte(SByte, SByte, Boolean)  Overloaded.
Returns a random 8bit signed integer that is within a specified range.
(Defined by RandomExtensions.)  
NextSingle  Overloaded.
Returns a random Single value that is greater than or equal to 0.0 and less than 1.0.
(Defined by RandomExtensions.)  
NextSingle(Single, FloatScale)  Overloaded.
Returns a nonnegative random Single value that is less or equal to the specified maxValue.
(Defined by RandomExtensions.)See the Remarks section for details.  
NextSingle(Single, Single, FloatScale)  Overloaded.
Returns a random Single value that is within a specified range.
(Defined by RandomExtensions.)See the Remarks section for details.  
NextString(StringCreation)  Overloaded.
Returns a random String using the specified strategy that has the length between 4 and 10 inclusive.
(Defined by RandomExtensions.)  
NextString(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.)  
NextString(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.)  
NextString(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.)  
NextString(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.)  
NextString(Int32, Int32, StringCreation)  Overloaded.
Returns a random String using the specified strategy that has the length between the specified range.
(Defined by RandomExtensions.)  
NextTimeSpan 
Returns a random TimeSpan that is between the specified range.
(Defined by RandomExtensions.)  
NextUInt16  Overloaded.
Returns a random 16bit unsigned integer that is less than UInt16.MaxValue.
To return any UInt16 use the SampleUInt16 method instead.
(Defined by RandomExtensions.)  
NextUInt16(UInt16, Boolean)  Overloaded.
Returns a random 16bit unsigned integer that is within the specified maximum.
(Defined by RandomExtensions.)  
NextUInt16(UInt16, UInt16, Boolean)  Overloaded.
Returns a random 16bit unsigned integer that is within a specified range.
(Defined by RandomExtensions.)  
NextUInt32  Overloaded.
Returns a random 32bit unsigned integer that is less than UInt32.MaxValue.
To return any UInt32 use the SampleUInt32 method instead.
(Defined by RandomExtensions.)  
NextUInt32(UInt32, Boolean)  Overloaded.
Returns a random 32bit unsigned integer that is within the specified maximum.
(Defined by RandomExtensions.)  
NextUInt32(UInt32, UInt32, Boolean)  Overloaded.
Returns a random 32bit unsigned integer that is within a specified range.
(Defined by RandomExtensions.)  
NextUInt64  Overloaded.
Returns a random 64bit unsigned integer that is less than UInt64.MaxValue.
To return any UInt64 use the SampleUInt64 method instead.
(Defined by RandomExtensions.)  
NextUInt64(UInt64, Boolean)  Overloaded.
Returns a random 64bit unsigned integer that is within the specified maximum.
(Defined by RandomExtensions.)  
NextUInt64(UInt64, UInt64, Boolean)  Overloaded.
Returns a random 64bit unsigned integer that is within a specified range.
(Defined by RandomExtensions.)  
SampleByte 
Returns a random Byte that can have any value.
(Defined by RandomExtensions.)  
SampleInt16 
Returns a random Int16 that can have any value.
(Defined by RandomExtensions.)  
SampleInt32 
Returns a random Int32 that can have any value.
(Defined by RandomExtensions.)  
SampleInt64 
Returns a random Int64 that can have any value.
(Defined by RandomExtensions.)  
SampleSByte 
Returns a random SByte that can have any value.
(Defined by RandomExtensions.)  
SampleUInt16 
Returns a random UInt16 that can have any value.
(Defined by RandomExtensions.)  
SampleUInt32 
Returns a random UInt32 that can have any value.
(Defined by RandomExtensions.)  
SampleUInt64 
Returns a random UInt64 that can have any value.
(Defined by RandomExtensions.)  
TryConvert(Type, Object)  Overloaded. (Defined by ObjectExtensions.)  
TryConvert(Type, CultureInfo, Object)  Overloaded. (Defined by ObjectExtensions.)  
TryConvertTTarget(TTarget)  Overloaded.
Tries to convert an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions.)See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.  
TryConvertTTarget(CultureInfo, TTarget)  Overloaded.
Tries to convert an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions.)See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example. 
See Also