DataTypeAttribute 构造函数  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 DataTypeAttribute 类的新实例。
重载
| DataTypeAttribute(DataType) | 使用指定的类型名初始化 DataTypeAttribute 类的新实例。 | 
| DataTypeAttribute(String) | 使用指定的字段模版名初始化 DataTypeAttribute 类的新实例。 | 
DataTypeAttribute(DataType)
- 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.DataTypeAttributePublic 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
使用指定的字段模版名初始化 DataTypeAttribute 类的新实例。
public:
 DataTypeAttribute(System::String ^ customDataType);public DataTypeAttribute (string customDataType);new System.ComponentModel.DataAnnotations.DataTypeAttribute : string -> System.ComponentModel.DataAnnotations.DataTypeAttributePublic Sub New (customDataType As String)参数
- customDataType
- String
要与数据字段关联的自定义字段模版名称。
例外
              customDataType 为 null 或空字符串 ("")。
注解
此方法提供了使用 特性的 UIHintAttribute 替代方法。