RandomNumberGenerator.GetBytes Method (Byte[], Int32, Int32)

.NET Framework (current version)
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Fills the specified byte array with a cryptographically strong random sequence of values.

Namespace:   System.Security.Cryptography
Assembly:  mscorlib (in mscorlib.dll)

public virtual void GetBytes(
	byte[] data,
	int offset,
	int count
)

Parameters

data
Type: System.Byte[]

The array to fill with cryptographically strong random bytes.

offset
Type: System.Int32

The index of the array to start the fill operation.

count
Type: System.Int32

The number of bytes to fill.

Exception Condition
ArgumentNullException

data is null.

ArgumentOutOfRangeException

offset or count is less than 0

ArgumentException

offset plus count exceeds the length of data.

.NET Framework
Available since 4.6
Return to top
Show: