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

注解

在特性化模型中使用此构造函数来确保分配给相关属性的值是整数。

适用于