IntegerValidator 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 IntegerValidator 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| IntegerValidator(Int32, Int32) |
初始化 IntegerValidator 類別的新執行個體。 |
| IntegerValidator(Int32, Int32, Boolean) |
初始化 IntegerValidator 類別的新執行個體。 |
| IntegerValidator(Int32, Int32, Boolean, Int32) |
初始化 IntegerValidator 類別的新執行個體。 |
IntegerValidator(Int32, Int32)
初始化 IntegerValidator 類別的新執行個體。
public:
IntegerValidator(int minValue, int maxValue);
public IntegerValidator(int minValue, int maxValue);
new System.Configuration.IntegerValidator : int * int -> System.Configuration.IntegerValidator
Public Sub New (minValue As Integer, maxValue As Integer)
參數
備註
此 IntegerValidator 構造子確保被驗證的整數同時遵守最小與最大長度。
適用於
IntegerValidator(Int32, Int32, Boolean)
初始化 IntegerValidator 類別的新執行個體。
public:
IntegerValidator(int minValue, int maxValue, bool rangeIsExclusive);
public IntegerValidator(int minValue, int maxValue, bool rangeIsExclusive);
new System.Configuration.IntegerValidator : int * int * bool -> System.Configuration.IntegerValidator
Public Sub New (minValue As Integer, maxValue As Integer, rangeIsExclusive As Boolean)
參數
- rangeIsExclusive
- Boolean
true 以指定驗證範圍為排他性。 包容性意指待驗證的價值必須在指定範圍內;排他性指的是必須低於最小值或高於最大值。
範例
以下程式碼範例示範如何使用 IntegerValidator 建構子。 此程式碼範例是本類別更大範例 IntegerValidator 的一部分。
// Create Validator for the range of 1 to 10 inclusive
int minIntVal = 1;
int maxIntVal = 10;
bool exclusive = false;
IntegerValidator integerValidator =
new IntegerValidator(minIntVal, maxIntVal, exclusive);
' Create Validator for the range of 1 to 10 inclusive
Dim minIntVal As Int32 = 1
Dim maxIntVal As Int32 = 10
Dim exclusive As Boolean = False
Dim validator As IntegerValidator = _
New IntegerValidator(minIntVal, maxIntVal, exclusive)
備註
在建立類別實例 IntegerValidator 時,此 IntegerValidator 建構子會檢查最小值與最大 Int32 值,以及驗證範圍是否為排他。 當參數 rangeIsExclusive 設為 true時,值 Int32 不得介於 minValue 和 maxValue 參數值之間。
適用於
IntegerValidator(Int32, Int32, Boolean, Int32)
初始化 IntegerValidator 類別的新執行個體。
public:
IntegerValidator(int minValue, int maxValue, bool rangeIsExclusive, int resolution);
public IntegerValidator(int minValue, int maxValue, bool rangeIsExclusive, int resolution);
new System.Configuration.IntegerValidator : int * int * bool * int -> System.Configuration.IntegerValidator
Public Sub New (minValue As Integer, maxValue As Integer, rangeIsExclusive As Boolean, resolution As Integer)
參數
例外狀況
備註
Int32被驗證的值必須等於該resolution值,才能通過驗證。