NextBytes Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

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

'Declaration
Public Overridable Sub NextBytes ( _
	buffer As Byte() _
)

Parameters

buffer
Type: array<System..::..Byte>[]()[][]
An array of bytes to contain random numbers.

ExceptionCondition
ArgumentNullException

buffer is nullNothingnullptrunita null reference (Nothing in Visual Basic).

Each element of the array of bytes is set to a random number greater than or equal to zero, and less than or equal to MaxValue.

To generate a cryptographically secured random number suitable for creating a random password, for example, use a method such as RNGCryptoServiceProvider..::..GetBytes.

Show: