Language

RangeAttribute コンストラクター

定義

RangeAttribute クラスの新しいインスタンスを初期化します。

オーバーロード

名前 説明
RangeAttribute(Double, Double)

指定した最小値と最大値を使用して、 RangeAttribute クラスの新しいインスタンスを初期化します。

RangeAttribute(Int32, Int32)

指定した最小値と最大値を使用して、 RangeAttribute クラスの新しいインスタンスを初期化します。

RangeAttribute(Type, String, String)

指定した最小値と最大値、および特定の型を使用して、 RangeAttribute クラスの新しいインスタンスを初期化します。

RangeAttribute(Double, Double)

ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs

指定した最小値と最大値を使用して、 RangeAttribute クラスの新しいインスタンスを初期化します。

public:
 RangeAttribute(double minimum, double maximum);
public RangeAttribute(double minimum, double maximum);
new System.ComponentModel.DataAnnotations.RangeAttribute : double * double -> System.ComponentModel.DataAnnotations.RangeAttribute
Public Sub New (minimum As Double, maximum As Double)

パラメーター

minimum
Double

データ フィールド値に使用できる最小値を指定します。

maximum
Double

データ フィールド値に使用できる最大値を指定します。

適用対象

RangeAttribute(Int32, Int32)

ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs

指定した最小値と最大値を使用して、 RangeAttribute クラスの新しいインスタンスを初期化します。

public:
 RangeAttribute(int minimum, int maximum);
public RangeAttribute(int minimum, int maximum);
new System.ComponentModel.DataAnnotations.RangeAttribute : int * int -> System.ComponentModel.DataAnnotations.RangeAttribute
Public Sub New (minimum As Integer, maximum As Integer)

パラメーター

minimum
Int32

データ フィールド値に使用できる最小値を指定します。

maximum
Int32

データ フィールド値に使用できる最大値を指定します。

例

次の例は、 RangeAttribute を使用して整数データ フィールドの範囲を指定する方法を示しています。

[Range(300, 3000)]
public object ListPrice;
<Range(300, 3000)> _
Public ListPrice As Object

適用対象

RangeAttribute(Type, String, String)

ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs
ソース:
RangeAttribute.cs

指定した最小値と最大値、および特定の型を使用して、 RangeAttribute クラスの新しいインスタンスを初期化します。

public:
 RangeAttribute(Type ^ type, System::String ^ minimum, System::String ^ maximum);
public RangeAttribute(Type type, string minimum, string maximum);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
public RangeAttribute(Type type, string minimum, string maximum);
new System.ComponentModel.DataAnnotations.RangeAttribute : Type * string * string -> System.ComponentModel.DataAnnotations.RangeAttribute
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")>]
new System.ComponentModel.DataAnnotations.RangeAttribute : Type * string * string -> System.ComponentModel.DataAnnotations.RangeAttribute
Public Sub New (type As Type, minimum As String, maximum As String)

パラメーター

type
Type

テストするオブジェクトの型を指定します。

minimum
String

データ フィールド値に使用できる最小値を指定します。

maximum
String

データ フィールド値に使用できる最大値を指定します。

属性

例外

type は nullです。

例

次の例は、 RangeAttribute メソッドを使用して、 DateTime フィールドの範囲を指定する方法を示しています。 また、 FormatErrorMessage メソッドの書式設定機能を使用する方法を示すカスタム エラー メッセージも含まれています。

[Range(typeof(DateTime), "1/2/2004", "3/4/2004",
    ErrorMessage = "Value for {0} must be between {1} and {2}")]
public object SellEndDate;
<Range(GetType(DateTime), "1/2/2004", "3/4/2004", _
       ErrorMessage:="Value for {0} must be between {1} and {2}")> _
Public SellEndDate As Object

注釈

検証するオブジェクトは、 IComparable インターフェイスを実装する必要があります。

適用対象