csharp System.ComponentModel.DataAnnotations.RegularExpressionAttribute类(方法)实例源码

下面列出了csharp System.ComponentModel.DataAnnotations.RegularExpressionAttribute 类(方法)源码代码实例,从而了解它的用法。

作者:.NET开发    项目:System.ComponentModel.DataAnnotation   
//引入命名空间
using System;
using System.Web.DynamicData;
using System.ComponentModel.DataAnnotations;

[MetadataType(typeof(CustomerMetaData))]
public partial class Customer
{
}

public class CustomerMetaData
{
   
    // Allow up to 40 uppercase and lowercase 
    // characters. Use custom error.
    [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$", 
         ErrorMessage = "Characters are not allowed.")]
    public object FirstName;

    // Allow up to 40 uppercase and lowercase 
    // characters. Use standard error.
    [RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$")]
    public object LastName;
}


问题


面经


文章

微信
公众号

扫码关注公众号