I was recently told that using Enum
:
public enum TaskEndState { Error, Completed, Running }
may have compatibility/serialization issues, and thus sometimes it's better to use const string:
public const string TASK_END_STATE = "END_STATE";
public const string TASK_END_STATE_ERROR = "TASK_END_STATE_ERROR";
public const string TASK_END_STATE_COMPLETE = "TASK_END_STATE_COMPLETE";
public const string TASK_END_STATE_RUNNING = "TASK_END_STATE_RUNNING";
Can you find practical use case where it may happen, is there any guidelines where Enum
's should be avoided?
Edit:
My production environment has multiple WFC services (different versions of the same product). A later version may/or may not include some new properties as Task end state (this is just an example). If we try to deserialize a new Enum
value in an older version of a specific service, it may not work.
TaskEndState
as an argument type to a string just because a small bit of code gets confused serializing enums. That just doesn't make sense to me.