C# Custom Attribute Required If
问题 I am just getting into custom attributes, and I absolutely love them. I am wondering if it is possible to create an attribute that gets applied to a property and denotes the name of another property in the same object. If would check to see if the referenced property has a value, and if so, the decorated attribute would be required. Something like this: [RequiredIfNotNull("ApprovedDate")] [DisplayName("Approved By")] [StringLength(50, ErrorMessage = "{0} must not exceed {1} characters")]