Enum ToString with user friendly strings

后端 未结 23 2143
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 11:44

My enum consists of the following values:

private enum PublishStatusses{
    NotCompleted,
    Completed,
    Error
};

I want to be able to

23条回答
  •  醉话见心
    2020-11-22 12:19

    If you want something completely customizable, try out my solution here:

    http://www.kevinwilliampang.com/post/Mapping-Enums-To-Strings-and-Strings-to-Enums-in-NET.aspx

    Basically, the post outlines how to attach Description attributes to each of your enums and provides a generic way to map from enum to description.

提交回复
热议问题