Re: [ADVANCED-DOTNET] ToString Implementation in an Enum

2003-06-23 Thread Merak
Either rename the Enum strings as per the display name (not a good idea), or use a Description attribute for each element, and use reflection to obtain the description. Of course neither of those methods is locale independent... Merak > -Original Message- > From: Moderated discussion of

Re: [ADVANCED-DOTNET] ToString Implementation in an Enum

2003-06-23 Thread Gert Lombard
Hi, This is not exactly what you asked for, but the closest I know of is to apply an attribute (System.ComponentModel.DescriptionAttribute works well) to each enum value and use Reflection to retrieve the value, e.g.: public enum MonetaryUnit { [Description("American")] USDoll

Re: [ADVANCED-DOTNET] ToString Implementation in an Enum

2003-06-23 Thread Joe Hershman
the enum declaration below is simply a c# language construct. but basically an enum is just a value type that has a bunch of static public fields, the real value of the each field is based on the underlying type (by default an int32). so something like this should work: public class MonetaryUn

Re: [ADVANCED-DOTNET] ToString Implementation in an Enum

2003-06-23 Thread Helen Warn
Here's how I have done it: public static string sMonetaryUnit(MonetaryUnit mu) { return Enum.Format(typeof(MonetaryUnit), mu, "G"); } hth Helen > -Original Message- > From: Moderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] Behalf Of Clark, Mich