In this post, I’ll explain how you can provide string values for an enum. Usually, we’ll assign integer (by default), long or as a bit field using FlagAttribute.
For assigning a string value first you need to create a class inherited from Attribute class.
Once your attribute class is ready. You can use the attribute and your string values as below:
Now, for accessing the enum string value and converting the string values to respective enum , it’s good to have an extension so that you can convert back and forth seamlessly.
Now, you are fully occupied for using the enum and its custom values. Below is an example on how to use it.
Hope this helps.