Share via


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)

Syntax

'Declaration
Public Overridable Sub NextBytes ( _
    buffer As Byte() _
)
public virtual void NextBytes(
    byte[] buffer
)
public:
virtual void NextBytes(
    array<unsigned char>^ buffer
)
abstract NextBytes : 
        buffer:byte[] -> unit 
override NextBytes : 
        buffer:byte[] -> unit 
public function NextBytes(
    buffer : byte[]
)

Parameters

Exceptions

Exception Condition
ArgumentNullException

buffer is null Nothing nullptr unit a null reference (Nothing in Visual Basic) .

Remarks

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.

.NET Framework Security

See Also

Reference

Random Class

System Namespace