我有一个共享的简单类。我有DataAnnotations来显示必填字段
public class Address
{
[Required]
public string Contact { get; set; }
[Required]
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Company{ get; set; }
}
在使用此课程的一个实例中,我需要使公司成为必需。只在需要时才需要公司的最佳方式是什么。
Address对象正在其他类中使用,例如Order,Account等。