Hey all,
Say you have an enum that represents an error code. There will be several codes, each with their own underlying int value; however, the enum value that gets the default 0 value seems like it should be carefully considered.
In the case of an error code enum, there are two special values that I can think of: None (for cases when there is no error) and Unknown (for cases when no existing error code is appropriate, or perhaps even when error state cannot be detected).
One of these values seems like it should get 0, where the other will probably get something else like -1. Is it more appropriate to set the None value to 0, or the Unknown value to 0?
public enum ErrorCode
{
None = -1,
Unknown = 0,
InsufficientPermissions,
ConnectivityError,
...
}
public enum ErrorCode
{
Unknown = -1,
None = 0,
InsufficientPermissions,
ConnectivityError,
...
}
My instinct tells me that the default should be Unknown, but I'm curious if anyone has done it differently.