|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Global ObjectsReally what I want is an enumeration that returns strings rather than
integers. Since, as far as I know, that's not possible, I thought to create a class with shared members that return strings. Kind of like a qualified constant list so that you can type the name of the class and then get, via intellisense, a list of the possible values. I thought that if I created a class with nothing but shared variables, I wouldn't have toi instantiate it before I used it, since the members were all shared. Kind of like using the Math object. You just use it, don't declare one first. However, it's not working. The compiler keeps complaining that I don't have an instance. How do I create a class that acts like a global instance? Thanks. Jerry <rlrcstr@newsgroups.nospam> schrieb:
> Really what I want is an enumeration that returns strings rather than If you are using VS 2005, check out the first source code listing at > integers. Since, as far as I know, that's not possible, I thought to > create a class with shared members that return strings. Kind of like a > qualified constant list so that you can type the name of the class and > then get, via intellisense, a list of the possible values. > > I thought that if I created a class with nothing but shared variables, I > wouldn't have toi instantiate it before I used it, since the members were > all shared. Kind of like using the Math object. You just use it, don't > declare one first. <URL:http://dotnet.mvps.org/dotnet/articles/enums/>. Creating enumerations of items with a certain arbitrary data type <URL:http://dotnet.mvps.org/dotnet/faqs/?id=anytypeenums&lang=en> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Hi Jerry,
Thanks for posting! Herfried's suggestion is appreciated! Since the enumeration type only allows the storage of numeric type, there are some other ways to approach the current demand. In addition, we can use the custom attributes to be a workaround. The following article from the CodeProject demonstrates how to use the StringValueAttribute for the enumeration type in C#: http://www.codeproject.com/csharp/stringenum.asp I hope this will be helpful. If you need a VB.NET version, please feel free to let me know. It's my pleasure to be a future assistance. Regards, Yuan Ren [MSFT] Microsoft Online Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were updated on February 14, 2006. Please complete a re-registration process by entering the secure code mmpng06 when prompted. Once you have entered the secure code mmpng06, you will be able to update your profile and access the partner newsgroups. ====================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ====================================================== This posting is provided "AS IS" with no warranties, and confers no rights. ====================================================== Interesting stuff.. Thanks.
""Yuan Ren[MSFT]"" <v-y***@microsoft.com> wrote in message Show quoteHide quote news:sDyJhD3OGHA.128@TK2MSFTNGXA01.phx.gbl... > Hi Jerry, > > Thanks for posting! > > Herfried's suggestion is appreciated! Since the enumeration type only > allows the storage of numeric type, there are some other ways to approach > the current demand. > > In addition, we can use the custom attributes to be a workaround. The > following article from the CodeProject demonstrates how to use the > StringValueAttribute for the enumeration type in C#: > http://www.codeproject.com/csharp/stringenum.asp > > I hope this will be helpful. If you need a VB.NET version, please feel > free > to let me know. It's my pleasure to be a future assistance. > > Regards, > > Yuan Ren [MSFT] > Microsoft Online Support > ====================================================== > PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were > updated on February 14, 2006. Please complete a re-registration process > by entering the secure code mmpng06 when prompted. Once you have > entered the secure code mmpng06, you will be able to update your profile > and access the partner newsgroups. > ====================================================== > When responding to posts, please "Reply to Group" via your newsreader > so that others may learn and benefit from this issue. > ====================================================== > This posting is provided "AS IS" with no warranties, and confers no > rights. > ====================================================== >
Splitting a large string variable into lines <= 70 chars
Form Wizard not working Headache about Error Handling and Debugging Custom size paper problem XML Commenting Links Scrolling a Datagrid with code Adding Dataview or datatables to static DataSet Saving Rich Text to a SQL Database Adding images to image folder in vb.net |
|||||||||||||||||||||||