共用方式為


RandomNumberGenerator.GetNonZeroBytes 方法

定義

多載

GetNonZeroBytes(Byte[])

在衍生類別中覆寫時,將在密碼編譯方面強式的非零值隨機序列填入位元組陣列。

GetNonZeroBytes(Span<Byte>)

填入密碼編譯強式隨機非零值序列位元組的範圍。

GetNonZeroBytes(Byte[])

來源:
RandomNumberGenerator.cs
來源:
RandomNumberGenerator.cs
來源:
RandomNumberGenerator.cs

在衍生類別中覆寫時,將在密碼編譯方面強式的非零值隨機序列填入位元組陣列。

public:
 virtual void GetNonZeroBytes(cli::array <System::Byte> ^ data);
public:
 abstract void GetNonZeroBytes(cli::array <System::Byte> ^ data);
public virtual void GetNonZeroBytes (byte[] data);
public abstract void GetNonZeroBytes (byte[] data);
abstract member GetNonZeroBytes : byte[] -> unit
override this.GetNonZeroBytes : byte[] -> unit
abstract member GetNonZeroBytes : byte[] -> unit
Public Overridable Sub GetNonZeroBytes (data As Byte())
Public MustOverride Sub GetNonZeroBytes (data As Byte())

參數

data
Byte[]

要將在密碼編譯方面強式的隨機非零位元組填入的陣列。

範例

下列範例會建立100個非零位元組的隨機序列,並將其儲存在 random中。

array<Byte>^ random = gcnew array<Byte>(100);
RandomNumberGenerator^ rng = RandomNumberGenerator::Create();
rng->GetNonZeroBytes( random ); // The array is now filled with cryptographically strong random bytes, and none are zero.
byte[] random = new byte[100];

using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
{
    rng.GetNonZeroBytes(random); // The array is now filled with cryptographically strong random bytes, and none are zero.
}
Dim random() As Byte = New Byte(100) {}

Using rng As RandomNumberGenerator = RandomNumberGenerator.Create()
    rng.GetNonZeroBytes(random) ' bytes in random are now random and none are zero
End Using

備註

位元組陣組的長度會決定產生多少個隨機位元組。

另請參閱

適用於

GetNonZeroBytes(Span<Byte>)

來源:
RandomNumberGenerator.cs
來源:
RandomNumberGenerator.cs
來源:
RandomNumberGenerator.cs

填入密碼編譯強式隨機非零值序列位元組的範圍。

public:
 virtual void GetNonZeroBytes(Span<System::Byte> data);
public virtual void GetNonZeroBytes (Span<byte> data);
abstract member GetNonZeroBytes : Span<byte> -> unit
override this.GetNonZeroBytes : Span<byte> -> unit
Public Overridable Sub GetNonZeroBytes (data As Span(Of Byte))

參數

data
Span<Byte>

要填入密碼編譯強式隨機非零位元組的範圍。

適用於