using System.ComponentModel.DataAnnotations;
//特性是个类,继承自Attribute
//系统自带特性
//自定义特性
class AccountViewModel
{
[Required]
[Display(Name ="邮箱")]
[Define("这是第一个特性的创建!")]
public string Email { get; set; }
}
/// <summary>
/// 创建特性
/// </summary>
public class DefineAttribute:Attribute
{
public DefineAttribute(string showInfo)
{
Console.WriteLine(showInfo);
}
}