W
Wiktor Zychla
I would like to be able to convert enums to their string representation but
I would like to be able to apply a custom formatting, so that I could write
for example:
enum E { a, b, c };
string s1 = E.a.ToString( "d" ); // returns for example 'a'
string s2 = E.a.ToString( "f" ); // returns for example 'this is an enum
value a'
for now I have several methods in special class
class EnumToString
{
string ConvertAToStringD { return ...; }
string ConvertAToStringF { return ...; }
}
but this looks rather ugly.
I've read about EnumConverter class but I am not sure if it is possible to
have several different custom formatting possibilities when using this
class.
could anyone enlighten me?
Thanks in advance.
Wiktor Zychla
I would like to be able to apply a custom formatting, so that I could write
for example:
enum E { a, b, c };
string s1 = E.a.ToString( "d" ); // returns for example 'a'
string s2 = E.a.ToString( "f" ); // returns for example 'this is an enum
value a'
for now I have several methods in special class
class EnumToString
{
string ConvertAToStringD { return ...; }
string ConvertAToStringF { return ...; }
}
but this looks rather ugly.
I've read about EnumConverter class but I am not sure if it is possible to
have several different custom formatting possibilities when using this
class.
could anyone enlighten me?
Thanks in advance.
Wiktor Zychla