DataTypeAttribute 构造函数

定义

初始化 DataTypeAttribute 类的新实例。

重载

名称 说明
DataTypeAttribute(DataType)

使用指定的类型名称初始化类的新实例 DataTypeAttribute

DataTypeAttribute(String)

使用指定的字段模板名称初始化类的新实例 DataTypeAttribute

DataTypeAttribute(DataType)

Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs

使用指定的类型名称初始化类的新实例 DataTypeAttribute

public:
 DataTypeAttribute(System::ComponentModel::DataAnnotations::DataType dataType);
public DataTypeAttribute(System.ComponentModel.DataAnnotations.DataType dataType);
new System.ComponentModel.DataAnnotations.DataTypeAttribute : System.ComponentModel.DataAnnotations.DataType -> System.ComponentModel.DataAnnotations.DataTypeAttribute
Public Sub New (dataType As DataType)

参数

dataType
DataType

要与数据字段关联的类型的名称。

示例

以下示例演示如何使用 DataTypeAttribute(DataType) 构造函数指定数据字段的替代类型。

// Add type information.
[DataType(DataType.EmailAddress)]
public object EmailAddress;
' Add type information.
<DataType(DataType.EmailAddress)> _
Public EmailAddress As Object

注解

该名称是枚举定义的 System.ComponentModel.DataAnnotations.DataType 值之一。

适用于

DataTypeAttribute(String)

Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs
Source:
DataTypeAttribute.cs

使用指定的字段模板名称初始化类的新实例 DataTypeAttribute

public:
 DataTypeAttribute(System::String ^ customDataType);
public DataTypeAttribute(string customDataType);
new System.ComponentModel.DataAnnotations.DataTypeAttribute : string -> System.ComponentModel.DataAnnotations.DataTypeAttribute
Public Sub New (customDataType As String)

参数

customDataType
String

要与数据字段关联的自定义字段模板的名称。

例外

customDataTypenull 或空字符串(“)。

注解

此方法提供使用特性的 UIHintAttribute 替代方法。

适用于