title: RegularExpression Attribute - Passing in a property field of a class
body: <p>I have created a class MobileNumberAnnotation that has a property which specifies the regex expression. Now that when I specify the RegularExpressionAttribute how do I tell it to get the value of this property as the pattern?</p>
  
  <pre><code>public class MobileNumberAnnotation
  {
      public string MobileFormat = "^(07(\\d ?){9})";
  }
  </code></pre>
  
  <p>I tried doing the following but I don't know why it doesn't work as it is expecting a a string pattern.</p>
  
  <pre><code>    [Required]
      [RegularExpressionAttribute(MobileNumberAnnotation.MobileFormat)]
      public int MobileNumber { get; set; }
  </code></pre>