I have an enumeration of values that come through an API.
Those names are good but there is one I want to change with data annotations but how do you do that?
My enumeration looks like :
public enum TopicType
{
All = 0,
Message=1,
CalendarEvent=2,
Upload=4,
ToDo=8,
ToDoList=16,
Document=32
}
I want to change the "ToDo" to "ToDoItem" when I'm coding but I can't change the value in the enumeration due to serialization of my enum-object so I'll have to use data annotations, any suggestions?
Regardless of why you want to change ToDo to ToDoItem (separate discussion), you can easily achieve it using the following approach:
public enum TopicType
{
All = 0,
Message=1,
CalendarEvent=2,
Upload=4,
[Display(Name = "ToDoItem")]
ToDo=8,
ToDoList=16,
Document=32
}
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With