string.Format in Data Annotation Validation Attributes
问题 Is there any way to set Data Annotation messages using formatted string instead of direct constant, I need to set required field ErrorMessage like in following code, but it gives me an error. [Required(ErrorMessage = string.Format(SystemMessages.Required, "First Name"))] public string FirstName { get; set; } SystemMessages is a constant file and it has following code, public const string Required = "{0} is required."; Is there any way to set attributes like this? 回答1: string.Format result is