語言

IntegerValidatorAttribute 建構函式

定義

建立一個新的類別實例 IntegerValidatorAttribute 。

public:
 IntegerValidatorAttribute();
public IntegerValidatorAttribute();
Public Sub New ()

範例

以下範例說明如何使用 IntegerValidatorAttribute 建構子。

[ConfigurationProperty("maxSize", DefaultValue = 1000,
    IsRequired = true)]
[IntegerValidator()]
public int MaxSize
{
    get
    {
        return (int)this["maxSize"];
    }
    set
    {
        this["maxSize"] = value;
    }
}
<ConfigurationProperty("maxSize", _
DefaultValue:=1000, _
IsRequired:=True), _
IntegerValidator()> _
Public Property MaxSize() As Integer
    Get
        Return Fix(Me("maxSize"))
    End Get
    Set(ByVal value As Integer)
        Me("maxSize") = value
    End Set
End Property

備註

你可以在屬性化模型中使用這個建構子,確保相關屬性的值是整數。

適用於