Fills a buffer with random bytes.
[Visual Basic] Overridable Public Sub NextBytes( _ ByVal buffer() As Byte _ ) [C#] public virtual void NextBytes( byte[] buffer ); [C++] public: virtual void NextBytes( unsigned char* buffer[] ); [JScript] public function NextBytes( buffer : Byte[] );
Exception Type | Condition |
---|---|
ArgumentNullException | if buffer is null. |
The seed is adjusted as a side effect of this call. That is, successive calls to NextBytes will yield different numbers.
[C++] Random *rnd = new Random (); [managed] unsigned char b[] = new [managed] unsigned char[10]; rnd->NextBytes(b); Console::WriteLine(L"The Random bytes are: "); for (int i = 0; i < 10; i++) { Console::Write(i); Console::Write(L": "); Console::WriteLine(b[i]); }