Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我在类或类属性上添加 CustomValidation,我如何从代码中触发它?
如果从一个类触发,那么你使用
Validator.ValidateObject(classNameToBeValidated, new ValidationContext(classNameToBeValidated,null,null);
如果在单个属性上使用 Validator.ValidateProperty....