Linked Questions
49 questions linked to/from Get int value from enum in C#
13
votes
4
answers
1k
views
How to get the int for enum value in Enumeration [duplicate]
If I had the value : "dog" and the enumeration:
public enum Animals
{
dog = 0 ,
cat = 1 ,
rat = 2
}
how could I get 0 for the value "dog" from Animals ?
EDIT:
I am wondering if there is index ...
15
votes
3
answers
2k
views
Enum to int best practice [duplicate]
I can't select between two methods of converting. What is the best practice by converting from enum to int
1:
public static int EnumToInt(Enum enumValue)
{
return Convert.ToInt32(enumValue);
}
...
5
votes
4
answers
839
views
How do I convert a string to an enum value to an integer? [duplicate]
Possible Duplicate:
How do I Convert a string to an enum in C#?
Enums returning int value
I have declare an enumeration:-
public enum Car
{
SELECT = 0,
AUDI = 1,
...
14
votes
1
answer
9k
views
How to get the numeric value from a flags enum? [duplicate]
Possible Duplicate:
Enums returning int value
How to get the numeric value from the Enum?
THIS IS NOT A DUPLICATE OF EITHER OF THESE, THANKS FOR READING THE QUESTION MODS
Suppose I have a ...
2
votes
3
answers
235
views
How to retrieve the integer value of an enum? [duplicate]
I have an enum
public enum Color
{
Red = 0,
Blue = 1,
Yellow = 2
}
When I do this:
Color color = Color.Blue;
Console.Writeline(color.Value);
I want to see it's integer-value (1 in this ...
9
votes
3
answers
685
views
display int value from enum [duplicate]
I have a propertygrid which I need to create a combobox inside the propertygrid and display int value (1 to 9), I found using enum is the easiest way, but enum couldn't display int value, even I try ...
1
vote
1
answer
2k
views
How do I get the int value from the EventLogEntryType enum [duplicate]
I am trying to get the numerical code from the EventLogEntryType enum type. I have a generic log method that will take this in addition to the message and write a windows event log before calling my ...
1
vote
2
answers
204
views
Enum with underlying type. Returning the string representation unintentionally [duplicate]
I have the following enum:
public enum BikeType : byte
{
Road = 0,
Mountain = 1
};
When I try to pass it to a I retrieve the 'string' representation of the byte, not the numeric value:
...
0
votes
1
answer
1k
views
Convert ENUM to int using CsvHelper [duplicate]
I'm using CsvHelper to write into csv file.
I want to write ENUM as int, not string.
What is the eassiesest way to do this?
Assuming I have some types of ENUM's, not just one.
public enum ...
-2
votes
1
answer
304
views
Getting enumerate value [duplicate]
Possible Duplicate:
Enums returning int value
I want to numerate "Stack", "Overflow" and "Stackoverflow". Therefore I use enumerate.
enum Status : int
{
Stack = 1,
Overflow = 2,
...
-2
votes
2
answers
518
views
What is enum in worl of OOP? as a custom variable why we use enum? [duplicate]
I would like to know more about enums in C#. is it best practice to use enum for creating custom variables? or we can use some another better approach for below example. How we can access it and store ...
2
votes
1
answer
180
views
Get a enum value [duplicate]
I am stuck with a piece code
There is a object, a field of which returns an enum (getter) the field is set by a function after reading from database. For example
Enum fiscalperiond
{
Num1 = 12;
...
0
votes
0
answers
116
views
C# How to convert Enum Value to Int [duplicate]
I have got an Enum List
public enum SkillName {
Mele_Offence,
Mele_Defence
}
Then my skills are setted up and modified on Player class
private void SetupSkillModifires () {
// mele ...
0
votes
2
answers
131
views
How to use enum in switch , if i need to use a number entered by user? [duplicate]
I simply need to use enum with entered number, but I don't know how to convert. Do I have to create an additional variable of int and than convert?
public enum Actions
{
...
0
votes
1
answer
46
views
how to include enum key and value inside SelectListItem? [duplicate]
I try to convert Enum to SelectListItem. I can get the text but I can't get the value itself.
here is my attempt.
// A method to convert Enum to SelectListItem
public static IEnumerable<...