473,586 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get Enum content via setting value

1 New Member
I want to get the content of Enum type by corresponding value.
For example
Expand|Select|Wrap|Line Numbers
  1. public enum color
  2. {
  3.     red = 1 , yellow = 2 , green = 3
  4.  
  5. }
How can I get the color via value 1 , 2 , 3.
Mar 22 '12 #1
1 1651
Frinavale
9,735 Recognized Expert Moderator Expert
Use the Enum.GetValues Method to get the "values" for the enums.

Use the Enum.GetNames Method to get the "names" of the enums.

Use the Enum.Parse Method convert the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object.

-Frinny
Mar 22 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1418
by: JKop | last post by:
Consider the following platform: char = 8-bit short = 16-bit int = 32-bit long = 32-bit
0
1118
by: CSDunn | last post by:
Hello, I have a subform where the 'Name' and 'Source Object' properties are both 'frmSelectByTestSUB'. This subform resides in a main form called 'frmSelectByTest'. In the subform, I have a combo box currently named 'Combo6' that displays a list of student names. I need to set up functionality so that after the name in the combo box is...
0
1258
by: CSDunn | last post by:
Hello, I have a subform where the 'Name' and 'Source Object' properties are both 'frmSelectByTestSUB'. This subform resides in a main form called 'frmSelectByTest'. In the subform, I have a combo box currently named 'Combo6' that displays a list of student names. I need to set up functionality so that after the name in the combo box is...
6
3638
by: David | last post by:
Hi, namespace EnumTest { class Class1 { public enum num { one = 1, uno = 1,
1
2963
by: George | last post by:
I am trying to set the value of items in a dropdown list dynamically, and can't seem to figure out how to do it. I have two arrays set up like this: Dim a() as string ={"A", "B", "C"} Dim b() as string ={"1", "2", "3"} I can get the first array in the items list like this:
6
7455
by: Rick | last post by:
I have a main form called frmDemo with a subform frmStageTrack_Sub. On the subform is a Combo Box CboTermID. The frmDemo is tied to tblDemo and the frmStageTrack_Sub is tied to tblStageTrack. What I would like to do is when a new record is created in frmDemo I would like to set the CboTermID on the subform to a default value, say 1, without...
0
5467
by: John | last post by:
Hi, I have set a DataGridViewComboBoxColumn for a complex object type, and set the DisplayMember and ValueMember to members of the object type. My problem is how to programmatically set the cell value. The objects live in the DataGridViewComboBoxColumn.Items, but there is no way of getting an object out based on, e.g. display value. ...
7
3797
by: Jan Spatina | last post by:
Hello, I have this type: enum days{sun = 1, mon, tue, wed, thu, fri, sat}; and I have char in which is stored a name of the day: char* day = "wed"; How can I recieve number of the day?
1
3709
by: vaskarbasak | last post by:
hi all, I am using mysql db.The table structure is given below. +-----------------+---------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------------------+------+-----+---------+-------+ | bulk_invoice_no | varchar(50)...
2
2048
by: mbalas2 | last post by:
I set the value of Total texbox through javascript, and Total texbox does show the changed value. But when i access the textbox while saving in the db, the value is reset to previous value (value before calling javascript). The textbox is in the GridView template column. function Total(totTxt,sunTxt,monTxt) { var...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.