Data annotations
public class Contact
{
[StringLength(10)]
public string FirstName { get; set; }
[StringLength(10)]
public string LastName { get; set; }
[Range(18, 30)]
public int Age { get; set; }
[RegularExpression(@"^[2-9]\d{2}-\d{3}-\d{4}$")]
public string Telephone { get; set; }
}Last updated
Was this helpful?