IntegerValidatorAttribute 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立一個新的類別實例 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
備註
你可以在屬性化模型中使用這個建構子,確保相關屬性的值是整數。