Re: enum ToString();

Chris Anderson <[email protected]> Mon, 27 Aug 2007 19:51:22 +0100
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
IMO you shouldn't be exposing Enum names or even descriptions of them
via attributes.

What happens when your client/users require different descriptions? Or
if you have multiple clients in different countries or that use a
different nomenclature?

Enum names are like constants and variable names - they are there for
the programmer NOT the end-user.

Personally I would use some sort of lookup table (in a database or a
config file) or even go the route of globalization.

Chris

> -----Original Message-----
> From: Discussion forum for developers using Windows Forms to build
apps
> and controls [mailto:[email protected]] On Behalf Of
> R. Rogers
> Sent: 27 August 2007 17:46
> To: [email protected]
> Subject: [DOTNET-WINFORMS] enum ToString();
> 
> Hi everyone,
> 
> I have the following declarations:
>         enum UploadTypes { utRPlus, utRdf, ut3000Extra, utBridge,
> utDealing
> };
>         UploadTypes UserSelectedUploadType;
> 
> Later on I have the following:
> UploadTypeCell.Value = UserSelectedUploadType.ToString();
> 
> Questions:
> Is an enum an object?
> Is there a way for me to override the ToString() method?
> If not, what would be ways for me to provide a description for each
> enumerated value?
>