NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Random.NextBytes

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[]
);

Parameters

buffer
array to contain random numbers.

Exceptions

Exception Type Condition
ArgumentNullException if buffer is null.

Remarks

The seed is adjusted as a side effect of this call. That is, successive calls to NextBytes will yield different numbers.

Example

[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]);
  }

See Also

Random Class | Random Members | System Namespace