Share via


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

備註

您會在屬性化模型中使用此建構函式,以確保指派給相關屬性的值是整數。

適用於