Re: enum ToString();
Garry Lenz <[email protected]> Mon, 27 Aug 2007 13:34:39 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <DOTNET-WINFORMS%[email protected]> |
Check out the following article on CodeProject... http://www.codeproject.com/csharp/stringenum.asp Garry > > From: Brady Kelly <[email protected]> > Date: 2007/08/27 Mon PM 01:21:50 EDT > To: [email protected] > Subject: Re: [DOTNET-WINFORMS] enum ToString(); > > You can use attributes to add a description to enum members. I just can't > recall which attribute. > > > -----Original Message----- > > From: Discussion forum for developers using Windows Forms to build apps > > and controls [mailto:[email protected]] On Behalf Of > > Girish Jain > > Sent: 08 July 2007 03:39 AM > > To: [email protected] > > Subject: Re: [DOTNET-WINFORMS] enum ToString(); > > > > Is an enum an object? > > An enum is a value type and not a reference type. Therefore, its not an > > object. Can be converted to object using boxing. > > > > Is there a way for me to override the ToString() method? > > I guess not. > > > > If not, what would be ways for me to provide a description for each > > enumerated value? > > Enumerated values are themselves descriptions for some integer sets of > > values. I believe you need to use set of **const** values for your > > purpose. > > > > I might be incorrect. If I am wrong, someone please correct!! > > > > -Girish Jain > > > > -----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/08/2007 10:05 PM > > 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? > > > > Richard >