Re: enum ToString();
Brady Kelly <[email protected]> Mon, 27 Aug 2007 19:21:50 +0200
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Organization | Chase Software |
| Message-ID | <[email protected]> |
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