RandomNumberGenerator.GetInt32 メソッド

定義

オーバーロード

名前 説明
GetInt32(Int32)

暗号強度の高い乱数ジェネレーターを使用して、0 (包括的) から指定された排他的上限までのランダム整数を生成します。

GetInt32(Int32, Int32)

暗号強度の高い乱数ジェネレーターを使用して、指定した包括下限と指定された排他的上限の間にランダムな整数を生成します。

GetInt32(Int32)

ソース:
RandomNumberGenerator.cs
ソース:
RandomNumberGenerator.cs
ソース:
RandomNumberGenerator.cs
ソース:
RandomNumberGenerator.cs
ソース:
RandomNumberGenerator.cs

暗号強度の高い乱数ジェネレーターを使用して、0 (包括的) から指定された排他的上限までのランダム整数を生成します。

public:
 static int GetInt32(int toExclusive);
public static int GetInt32(int toExclusive);
static member GetInt32 : int -> int
Public Shared Function GetInt32 (toExclusive As Integer) As Integer

パラメーター

toExclusive
Int32

ランダム範囲の排他的上限。

返品

0 (包括) から toExclusive (排他的) までのランダムな整数。

例外

toExclusive パラメーターは 0 以下です。

注釈

上限は、配列、スパン、またはリストから長さの値を渡せるようにするために排他的です。 これは排他的な上限であるため、このメソッドは Int32.MaxValueを生成できません。

このメソッドでは、破棄と再試行の方法を使用して、単純なモジュール式の算術演算で生成される低い値のバイアスを回避します。

適用対象

GetInt32(Int32, Int32)

ソース:
RandomNumberGenerator.cs
ソース:
RandomNumberGenerator.cs
ソース:
RandomNumberGenerator.cs
ソース:
RandomNumberGenerator.cs
ソース:
RandomNumberGenerator.cs

暗号強度の高い乱数ジェネレーターを使用して、指定した包括下限と指定された排他的上限の間にランダムな整数を生成します。

public:
 static int GetInt32(int fromInclusive, int toExclusive);
public static int GetInt32(int fromInclusive, int toExclusive);
static member GetInt32 : int * int -> int
Public Shared Function GetInt32 (fromInclusive As Integer, toExclusive As Integer) As Integer

パラメーター

fromInclusive
Int32

ランダム範囲の包括下限。

toExclusive
Int32

ランダム範囲の排他的上限。

返品

fromInclusive (包括) とtoExclusive (排他的) の間のランダムな整数。

例外

toExclusive パラメーターは、fromInclusive パラメーター以下です。

注釈

上限は、配列、スパン、またはリストから長さの値を渡せるようにするために排他的です。 これは排他的な上限であるため、このメソッドは Int32.MaxValueを生成できません。

このメソッドでは、破棄と再試行の方法を使用して、単純なモジュール式の算術演算で生成される低い値のバイアスを回避します。

負の値は、 fromInclusivetoExclusiveの両方で使用できます。

適用対象