473,382 Members | 1,349 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,382 software developers and data experts.

Getting the value of an enum

Hello,

I have a simple question. If there is an enum:

public enum Hello
{
First = 1,
Second = 2,
Third = 3
}

How do I get the integer value for the selected enum.

Hello thisHello = Hello.Second;
int SelectedValue = [??thisHello.Value??];

Thanks for your help!
Nov 17 '05 #1
2 2475
"Mark Fox" <in**@solelsoftware.com> wrote in message
news:04****************************@phx.gbl...
Hello,

I have a simple question. If there is an enum:

public enum Hello
{
First = 1,
Second = 2,
Third = 3
}

How do I get the integer value for the selected enum.

Hello thisHello = Hello.Second;
int SelectedValue = [??thisHello.Value??];


int SelectedValue = (int) thisHello;
--
John

Nov 17 '05 #2

Thanks John! That answers my question.
-----Original Message-----
"Mark Fox" <in**@solelsoftware.com> wrote in message
news:04****************************@phx.gbl...
Hello,

I have a simple question. If there is an enum:

public enum Hello
{
First = 1,
Second = 2,
Third = 3
}

How do I get the integer value for the selected enum.

Hello thisHello = Hello.Second;
int SelectedValue = [??thisHello.Value??];


int SelectedValue = (int) thisHello;
--
John

.

Nov 17 '05 #3

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

Similar topics

20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
0
by: lglmi | last post by:
'********************START OF BAS MODULE******************** Option Explicit Private Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long...
5
by: Erol | last post by:
How do I get a type from a string? I'm retrieving a string value from my database so that I can set my property values dynamically. In the event "Form1_Load", you will see that I'm trying to set...
3
by: Scott Liu | last post by:
HI, All, I have a web service doing a string search. It has an operator and a searchValue field. The operator is defined as an attribute and required. The xml is as below. <!--...
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
6
by: Rico | last post by:
Hello, I'm looking for a way to reference the string name of an enumerator. I know in VB.net you can do "MyEnum.ToString" and get the name instead of the integer value. Is there a way I can do...
10
by: Cliff | last post by:
Greetings, I have been trying to teach myself C++ over the past few weeks and have finally came across a problem I could not fix. I made a simple program that prints out a square or rectangle...
3
by: Adrian | last post by:
In the following code example I am trying to create a generic interface for a bunch of objects. Each concrete type is stored in its own container and the a container of pointer's to base is used so I...
3
by: Gangreen | last post by:
I have the following enum. ** * An enum to represent types of mechanics. * * @author * @version 1.0 */ public enum Mechanics { ISOLATION(0),
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.