RandomExtensionsSampleBigInteger Method

Returns a random BigInteger that represents an integer of byteSize bytes.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.2.0
C#
public static BigInteger SampleBigInteger(
	this Random random,
	int byteSize,
	bool isSigned = false
)

Parameters

random  Random
The Random instance to use.
byteSize  Int32
Determines the range of the generated value in bytes. For example, if this parameter is 1, then the result will be between 0 and 255 if isSigned is , or between -128 and 127 if isSigned is .
isSigned  Boolean  (Optional)
to generate a signed result; otherwise, . This parameter is optional.
Default value: .

Return Value

BigInteger
A random BigInteger that represents an integer of byteSize bytes.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Random. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullExceptionrandom is .
ArgumentOutOfRangeExceptionbyteSize is negative.
OverflowExceptionbyteSize is too large.
OutOfMemoryExceptionbyteSize is too large.

See Also