473,473 Members | 2,153 Online
Bytes | Software Development & Data Engineering Community
Create 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 1646
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
by: JKop | last post by:
Consider the following platform: char = 8-bit short = 16-bit int = 32-bit long = 32-bit
0
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...
0
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...
6
by: David | last post by:
Hi, namespace EnumTest { class Class1 { public enum num { one = 1, uno = 1,
1
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()...
6
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. ...
0
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...
7
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
by: vaskarbasak | last post by:
hi all, I am using mysql db.The table structure is given below. +-----------------+---------------------------+------+-----+---------+-------+ | Field | Type ...
2
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.