Skip to main content
Filter by
Sorted by
Tagged with
1812 votes
15 answers
726k views

From time to time I see an enum like the following: [Flags] public enum Options { None = 0, Option1 = 1, Option2 = 2, Option3 = 4, Option4 = 8 } I don't understand what ...
Brian Leahy's user avatar
  • 35.8k
1140 votes
43 answers
1.3m views

I'm mainly a C# developer, but I'm currently working on a project in Python. How can I represent the equivalent of an Enum in Python?
2407 votes
32 answers
1.7m views

Say I have an enum which is just public enum Blah { A, B, C, D } and I would like to find the enum value of a string, for example "A" which would be Blah.A. How would it be possible to ...
Malachi's user avatar
  • 33.9k
600 votes
29 answers
451k views

I would like to know if it is possible to get attributes of the enum values and not of the enum itself? For example, suppose I have the following enum: using System.ComponentModel; // for ...
Alex K's user avatar
  • 11.3k
1472 votes
31 answers
813k views

I have a class that contains an enum property, and upon serializing the object using JavaScriptSerializer, my json result contains the integer value of the enumeration rather than its string "...
Omer Bokhari's user avatar
481 votes
11 answers
176k views

I've got an enum like this: public enum MyLovelyEnum { FirstSelection, TheOtherSelection, YetAnotherOne }; I got a property in my DataContext: public MyLovelyEnum VeryLovelyEnum { get; ...
Sam's user avatar
  • 29.2k
768 votes
9 answers
552k views

I heard a few people recommending to use enum classes in C++ because of their type safety. But what does that really mean?
Oleksiy's user avatar
  • 40.3k
612 votes
29 answers
425k views

While browsing Stack Overflow I came across java singleton instantiation. It references an enum being used in a singleton pattern. I have been learning to write programs for couple of years now, and ...
MatBanik's user avatar
  • 26.9k
179 votes
7 answers
306k views

I'm creating a set of enum values, but I need each enum value to be 64 bits wide. If I recall correctly, an enum is generally the same size as an int; but I thought I read somewhere that (at least in ...
mipadi's user avatar
  • 414k
99 votes
5 answers
101k views

Consider the following typescript enum: enum MyEnum { A, B, C }; If I want another type that is the unioned strings of the keys of that enum, I can do the following: type MyEnumKeysAsStrings = keyof ...
Stephan G's user avatar
  • 3,527
504 votes
5 answers
775k views

I have an enum with Description attributes like this: public enum MyEnum { Name1 = 1, [Description("Here is another")] HereIsAnother = 2, [Description("Last one")] LastOne = 3 } I ...
davekaro's user avatar
  • 6,471
447 votes
29 answers
562k views

I just noticed that you can not use standard math operators on an enum such as ++ or +=. So what is the best way to iterate through all of the values in a C++ enum?
Adam's user avatar
  • 26.6k
234 votes
6 answers
165k views

I have read that it is possible to implement Singleton in Java using an Enum such as: public enum MySingleton { INSTANCE; } But, how does the above work? Specifically, an Object has to be ...
Anand's user avatar
  • 21.5k
101 votes
20 answers
127k views

Here's what I am trying to do: typedef enum { ONE, TWO, THREE } Numbers; I am trying to write a function that would do a switch case similar to the following: char num_str[10]; int ...
zxcv's user avatar
  • 7,721
735 votes
45 answers
1.1m views

I would like to iterate a TypeScript enum object and get each enumerated symbol name, for example: enum myEnum { entry1, entry2 } for (var entry in myEnum) { // use entry's name here, e.g., "...
CalvinDale's user avatar
  • 9,851
182 votes
7 answers
27k views

I thought I understood Java generics pretty well, but then I came across the following in java.lang.Enum: class Enum<E extends Enum<E>> Could someone explain how to interpret this type ...
Dónal's user avatar
  • 188k
1786 votes
8 answers
1.0m views

public enum Foos { A, B, C } Is there a way to loop through the possible values of Foos? Basically? foreach(Foo in Foos)
divinci's user avatar
  • 23.3k
2226 votes
15 answers
1.1m views

I know that Java enums are compiled to classes with private constructors and a bunch of public static members. When comparing two members of a given enum, I've always used .equals(), e.g. public ...
Matt Ball's user avatar
  • 361k
134 votes
11 answers
195k views

Is there a possibility to convert enumerator names to string in C?
Misha's user avatar
  • 5,409
222 votes
11 answers
196k views

For the life of me, I can't remember how to set, delete, toggle or test a bit in a bitfield. Either I'm unsure or I mix them up because I rarely need these. So a "bit-cheat-sheet" would be nice to ...
steffenj's user avatar
  • 8,105
210 votes
13 answers
82k views

I've been programming in Java for a while and just got thrown onto a project that's written entirely in C#. I'm trying to come up to speed in C#, and noticed enums used in several places in my new ...
Ogre Psalm33's user avatar
  • 22.1k
112 votes
4 answers
104k views

I want to make a selectOneMenu dropdown so I can select a status on my question. Is it possible to make the f:selectItem more flexible considering what happens if the order of the enums changes, and ...
LuckyLuke's user avatar
  • 49.2k
615 votes
42 answers
334k views

enum Suit: String { case spades = "♠" case hearts = "♥" case diamonds = "♦" case clubs = "♣" } For example, how can I do something like: for suit in Suit { // do something with ...
Lucien's user avatar
  • 8,413
136 votes
15 answers
315k views

If I have an enum like this: enum Errors { ErrorA = 0, ErrorB, ErrorC, }; Then I want to print it out to console: Errors anError = ErrorA; std::cout << anError; // 0 will be printed ...
zeroboo's user avatar
  • 9,213
194 votes
18 answers
174k views

I am very familiar with C# but starting to work more in Java. I expected to learn that enums in Java were basically equivalent to those in C# but apparently this is not the case. Initially I was ...
Craig W's user avatar
  • 4,560

1
2 3 4 5
62