Share via


IntegerValidatorAttribute.MaxValue 屬性

定義

取得或設定此屬性所允許的最大值。

public:
 property int MaxValue { int get(); void set(int value); };
public int MaxValue { get; set; }
member this.MaxValue : int with get, set
Public Property MaxValue As Integer

屬性值

整數,表示允許的最大值。

例外狀況

選取的值小於 MinValue

範例

下列範例將示範如何使用 MaxValue 屬性。

[ConfigurationProperty("maxAttempts", DefaultValue = 101,
    IsRequired = true)]
[IntegerValidator(MinValue = 1, MaxValue = 100,
    ExcludeRange = true)]
public int MaxAttempts
{
    get
    {
        return (int)this["maxAttempts"];
    }
    set
    {
        this["maxAttempts"] = value;
    }
}
<ConfigurationProperty("maxAttempts", _
DefaultValue:=101, _
IsRequired:=True), _
IntegerValidator(MinValue:=1, _
MaxValue:=100, _
ExcludeRange:=True)> _
Public Property MaxAttempts() As Integer
    Get
        Return Fix(Me("maxAttempts"))
    End Get
    Set(ByVal value As Integer)
        Me("maxAttempts") = value
    End Set
End Property

備註

MaxValue屬性值會包含在允許的範圍中。

適用於