473,395 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

enum contain string

Cc
is there a way to create enum that contain string?
Nov 20 '05 #1
2 1754
* "Cc" <ko*****@singnet.com.sg> scripsit:
is there a way to create enum that contain string?


"No."

My FAQ:

\\\
Imports System.ComponentModel
Imports System.Reflection

..
..
..
MsgBox(GetDescription(Weekdays.Wed))
..
..
..

Private Enum Weekdays
<Description("Sunday.")> _
Sun
<Description("Monday.")> _
Mon
<Description("Tuesday.")> _
Tue
<Description("Wednesday.")> _
Wed
<Description("Thursday.")> _
Thu
<Description("Friday.")> _
Fri
<Description("Saturday.")> _
Sat
End Enum

Private Function GetDescription(ByVal EnumConstant As [Enum]) As String
Dim fi As FieldInfo = EnumConstant.GetType().GetField(EnumConstant.ToStr ing())
Dim aattr() As DescriptionAttribute = _
DirectCast( _
fi.GetCustomAttributes(GetType(DescriptionAttribut e), False), _
DescriptionAttribute() _
)
If aattr.Length > 0 Then
Return aattr(0).Description
Else
Return EnumConstant.ToString()
End If
End Function
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
"Cc" <ko*****@singnet.com.sg> schrieb
is there a way to create enum that contain string?


http://groups.google.com/groups?selm...TNGP09.phx.gbl

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Fao | last post by:
Hi, I am in my first year of C++ in college and my professor wants me to Write a Program with multiple functions,to input two sets of user-defined data types: One type named 'Sign' declared by...
6
by: James Brown | last post by:
Hi, I have the following enum declared: enum TOKEN { TOK_ID = 1000, TOK_NUMBER, TOK_STRING, /*lots more here*/ }; What I am trying to do is _also_ represent ASCII values 0-127 as TOKENs...
2
by: Stephan Schulz | last post by:
Hi, in my standard scanner/parser package I am using a typedef enum to enumerate possible tokens, with each token type corresponding to a power of two, somewhat like the following: typedef...
18
by: Nebula | last post by:
Consider enum Side {Back,Front,Top,Bottom}; enum Side a; Now, why is a = 124; legal (well it really is an integer, but still, checking could be performed..) ? Wouldn't enums be more useful if...
3
by: ssg31415926 | last post by:
I have an abstract base class with an enum which is passed into a method. I want my derived classes to be able to add new values to the enum without having to redefine it and I want to be able to...
11
by: Charles Law | last post by:
Hi Guys I'm sure there is a plausible explanation for this, but ... <code> Public Enum Test Abra = 5 Cadabra = 76 End Enum
6
by: Michael Isaacs | last post by:
Regarding use of enum's, I am wondering what the cost of memory is when creating the enumeration on the calling side, and then using it on the function/method side. See example below. If I...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
3
by: hta1984 | last post by:
In my homework i need to use enum type input,and these inputs will contain a port number and a description. Here is the input: HTTP : 80 “Hypertext Transfer Protocol” SSH : 22 “Secure Shell” ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.