以他们的 GitHub为例,如果我在运行时知道名字只能是“Bob”或“Bill”,我可以对此进行验证吗?
public class Person
{
[Required]
public string FirstName { get; set; }
public string MiddleName { get; set; }
[Required]
public string LastName { get; set; }
public Gender Gender { get; set; }
[Range(2, 5)]
public int NumberWithRange { get; set; }
public DateTime Birthday { get; set; }
public Company Company { get; set; }
public Collection<Car> Cars { get; set; }
}