How to have enum values with spaces? [duplicate]

No that’s not possible, but you can attach attributes to enum members. The EnumMemberAttribute is designed exactly for the purpose you described.

public enum PersonGender
{
    Unknown = 0,
    Male = 1,
    Female = 2,
    Intersex = 3,
    Indeterminate = 3,

    [EnumMember(Value = "Not Stated")]
    NonStated = 9,

    [EnumMember(Value = "Inadequately Described")]
    InadequatelyDescribed = 9
}

For more information on how to use the EnumMemberAttribute to convert strings to enum values, see this thread.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)