Linked Questions

13 votes
4 answers
1k views

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 ...
mathinvalidnik's user avatar
15 votes
3 answers
2k views

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); } ...
zrabzdn's user avatar
  • 995
5 votes
4 answers
839 views

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, ...
user1327064's user avatar
  • 4,347
14 votes
1 answer
9k views

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 ...
DaveDev's user avatar
  • 42.4k
2 votes
3 answers
235 views

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 ...
Natrium's user avatar
  • 31.3k
9 votes
3 answers
685 views

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 ...
Mers Tho's user avatar
  • 159
1 vote
1 answer
2k views

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 ...
Iofacture's user avatar
  • 685
1 vote
2 answers
204 views

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: ...
nf313743's user avatar
  • 4,267
0 votes
1 answer
1k views

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 ...
rety's user avatar
  • 59
-2 votes
1 answer
304 views

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, ...
Stack User's user avatar
  • 1,398
-2 votes
2 answers
518 views

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 ...
Nixit Ahir's user avatar
  • 2,425
2 votes
1 answer
180 views

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; ...
user3048027's user avatar
0 votes
0 answers
116 views

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 ...
Dimon Olenov's user avatar
0 votes
2 answers
131 views

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 { ...
born2drum 2's user avatar
0 votes
1 answer
46 views

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<...
user avatar

15 30 50 per page