Tom Kerkhove Tom Kerkhove - 1 month ago 9
C# Question

Custom names to enumeration values

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?

Answer

I think You can try over [Display()] Annotation.

I hope this what you are expecting..