If I have the following:
public enum TYPE
{
One = 1,
Two = 2,
Three = 3
}
When I do:
var a = TYPE.One;
I would like it to populate the variable a with a string in the format “01”. In other words two digits with a leading zero.
Is it possible to do this by assigning some method to the SomeEnum? I realized I could use TYPE.One.ToString(“00”)but I would like to have it self-contained in the enum and something very simple to use.
can do something like this :
and after use this like:
Yes, conceptually it’s the same as like declaring a string , but it’s hidden inside extension method.
Other solution is: to simply avoid, at this point, using
enumsin that way.