S
Suresh
Hi,
I need to add a custom ToString method on an Enum
Property. The default ToString method expands the whole
name. But, I want only an short associated code with the
long name of the enum type.
For example,
public enum Color { Red = 0, Blue, Green }
The statement
Color cr = Color.Red;
Console.WriteLine(cr.ToString());
prints, "Red". But, I want to override ToString of Color
to yeild a result "RD" for red. "BL" for Blue and "GR" for
green.
Can anyone help me out?
Thanks and Best Regards
Suresh.
I need to add a custom ToString method on an Enum
Property. The default ToString method expands the whole
name. But, I want only an short associated code with the
long name of the enum type.
For example,
public enum Color { Red = 0, Blue, Green }
The statement
Color cr = Color.Red;
Console.WriteLine(cr.ToString());
prints, "Red". But, I want to override ToString of Color
to yeild a result "RD" for red. "BL" for Blue and "GR" for
green.
Can anyone help me out?
Thanks and Best Regards
Suresh.