I want to create PossibleValuesAttribute :
<code>[PossibleValues("Single", "Divorced")]
public string MaritalStatus { get; set; }
</code>
<code>[PossibleValues("Single", "Divorced")]
public string MaritalStatus { get; set; }
</code>
[PossibleValues("Single", "Divorced")]
public string MaritalStatus { get; set; }
It should throw an exeception if the value given to MaritalStatus
does not match either Single
or Divoced
.
I want the code to be clean. Is it possible to use some sort of middleware + reflection to achieve this ?