var context = new ValidationContext(obj1); Validator.TryValidateObject(obj1, context, null); context.Clear(); // reset context before validating another object var context2 = new ValidationContext(obj2); Validator.TryValidateObject(obj2, context2, null);
var context = new ValidationContext(obj); var errors = new ListThis method is part of the System.ComponentModel.DataAnnotations namespace in the .NET Framework.(); Validator.TryValidateObject(obj, context, errors); // clear errors from context context.Clear(); // validate again without errors Validator.TryValidateObject(obj, context, errors);