Most voted "enums" questions
A type of data consisting of a set of named values, called elements, members or Enumerators of the type. The tag can be used whenever this data type is used language-independent. Do not use Enum-java or other variation to indicate that it is about the Enum of a language. The individual tag of the language will indicate this.
Learn more…115 questions
Sort by count of
- 
		42 votes1 answer27667 viewsWhy and when to use Enum in Java?Someone who is learning the language, novice or experienced, may never have crossed paths with Java enumerations. I have read several times that they are useful, for example, to implement the… 
- 
		21 votes2 answers11055 viewsWhat is the advantage of using the ENUM type?When I should use the guy ENUM because even today where I saw this guy being used he could be replaced by VARCHAR or even for a simple CHAR, I can’t see a case where in it it really becomes… 
- 
		15 votes4 answers1443 viewsShould an enumeration be constant in the lifetime of the solution?Modern languages often have a type of enumeration that is usually a range of related constants. Its members are usually constant. In most languages this is even guaranteed by the compiler. But… software-engineering encoding-style enums constant lifespanasked 11 years, 4 months ago Maniero 444,682
- 
		14 votes6 answers2762 viewsHow to walk an Enum?Here’s what I need to do: string and go through it and pick up each letter found and add with its corresponding value, type: a = 1, s = 19 and etc. Well, I made a enum with all the values of string,… 
- 
		13 votes1 answer443 viewsIs an immutable Enummap thread safe?An immutable map built on top of a EnumMap could be used in multi-thread environment or there is some risk of competition problems? public enum MyEnum { VALUE1, VALUE2, VALUE3, VALUE4; } private… 
- 
		12 votes3 answers2210 viewsWhat is the purpose of the builder of an Enum?In Java constructors are required to create an object in memory, i.e., to instantiate the class that has been defined. Meanwhile, I discovered that a Enum has a builder, but he is not a class, and I… 
- 
		10 votes1 answer3523 viewsConvert int or string to EnumHow to convert type variables int and string for a enum? 
- 
		9 votes2 answers2594 viewsWhat does it mean and how does an Enum work with the [Flags] attribute?I was seeing how the class works FileInfo and came across an Enum: [Serializable] [ComVisible(true)] [Flags] public enum FileAttributes { ReadOnly = 1, Hidden = 2, System = 4, Directory = 16,… 
- 
		9 votes4 answers1531 viewsHow to assign a value to an Enum with binary notation?To work with hexadecimal numbers, just add 0x in front of the number, this way: var numeroHexa = 0xff1120; The same goes for octal numbers, adding the 0: var numeroOct = 037; But how do you declare… 
- 
		9 votes3 answers11758 viewsWhen to use const and when to use #defineSince the two do the same function there is some difference between one and the other? I’ll take the code from this site as an example C - Constants & Literals The #define Preprocessor #include… 
- 
		8 votes2 answers2353 viewsHow to get the integer value of one of the constants of an Enum?I have an Enum (enumeration) calling Notas and need to obtain the integer corresponding to one of its constants. public enum Nota { Otimo = 5, MuitoBom = 4, Bom = 3, Regular = 2, Ruim = 1,… 
- 
		8 votes2 answers2113 viewsHow to create methods on an Enum?I have an application in Java and am porting it to C#. I have a question regarding enum that seems to work differently from Java. After asking a question here on the site (Enumerations may contain… 
- 
		8 votes2 answers10963 viewsWhat is the difference between SET and ENUM in Mysql?What are the differences between SET and ENUM in Mysql? And in what situations both are best applied? 
- 
		8 votes1 answer179 viewsIs it possible to work with Javascript Enumerators?Commonly used in several languages Enumerators make life easier for developers when they need to create a "list" of values within an application. Within the Javascript it is possible to use this… 
- 
		7 votes1 answer204 viewsWhat does the "OR" operator do in an Enum?What the logical operator | (or) does so in that Enum? public enum Status { Running = 1, Inactive = 2, Error = Inactive | Running } 
- 
		7 votes2 answers1209 viewsCan Enum values only be integer?Studying C#, I came across a situation, I want to receive a value (string) by the console. And then compare it to the value of a Enum. For example: [Serializable] public enum Command { Exit =… 
- 
		7 votes2 answers607 viewsResource on an EnumI have a enum and would like to change the Description with Resource: public enum SystemArea { [Description("Gestor")] Gestor = 3, [Description("Administrador")] Administrador = 2,… 
- 
		6 votes1 answer68 viewsAre Java enumerations anti-performance?In a project I thought of exchanging whole ones for enumbut a colleague told me that enums are anti performatic. 
- 
		5 votes1 answer125 viewsHow to show correct name on an Enum bitwise?I have this one marked as [Flag], ie, are values in bit [Flags] public enum Position { None, Left, Right, Both=3 } Setei to Both(both) position in 3 why if it is Left and Right at the same time, it… 
- 
		5 votes2 answers243 viewsCast problem in a generic method that receives an array of Enum’s (Enum[])I intend to make a generic method that receives a enum[] and that a string representing the items of array comma-separated. public static string ToSeparatedCommaString<T>(T[] enums) where T :… 
- 
		5 votes3 answers2023 viewsIs there a nomenclature standard for enums?I don’t know much about object naming patterns. I’m creating a enum who lists positions, for example: manager, programmer, attendant... There is a pattern to name this Enum? EnumCargo, CargoEnum,...… 
- 
		5 votes2 answers1831 viewsHow to recover the description of an enumerator?I have the following enumerator public enum MeuEnumerador { [Description("Descrição do item do enumerador")] Enumerador1 = 1, [Description("Outra descrição")] Enumerador2 = 2 } How do I get the… 
- 
		5 votes2 answers1642 viewsHow do you convert an Enum guy into a list?Is there any way to convert a Enum in List? public enum TiposHospedagem { Casa = 1, Hotel = 2, Pousada = 3, CasaCampo = 4 } I’m trying to run the enum and add to the list, but the foreach does not… 
- 
		5 votes1 answer772 viewsEnum as Object Value in DDDAfter many searches on the internet, I came across many divergent opinions... In my application, I created the enum EstadoCivil {Casado = 1, Solteiro = 2, Divorciado = 3}. It can be classified as an… 
- 
		5 votes1 answer437 viewsHow to work with CHAR-like Enums using C# and Entity FrameworkI would like to know how to map my entity using an Enum of the type char by the Entity Framework, using Fluentapi. I have the following Enum: public enum Zona { Norte = 'N', Sul = 'S' } And my… 
- 
		4 votes1 answer330 viewsCan enumerations contain methods?I don’t know if that’s the term, "abstract methods in a enum". My doubt arose after seeing this implementation in code review. Until then I had never seen this kind of thing in any tutorial or… 
- 
		4 votes2 answers3911 viewsWhat is the difference between data types Enum, struct and Union in C?I am reading the GNU’s C manual and I’m in the data types section and I notice a certain similarity between the types enum, struct, and union. Is the syntax the same, or is there something that… 
- 
		4 votes1 answer64 views
- 
		4 votes2 answers544 viewsMap Enum with search conditionsI have a class that makes the search conditions as follows: public enum EnumCondicao { [Display(Name = "Igual")] Igual, [Display(Name = "Diferente")] Diferente, [Display(Name = "Maior")] Maior,… 
- 
		4 votes3 answers315 viewsWould it be possible to list Enum from a table field through a query?I wonder if there is any way to bring the values of the inserted in the ENUM of a table column through a query. For example, with this table: CREATE TABLE shirts ( name VARCHAR(40), size… 
- 
		4 votes1 answer64 viewsCompiler indicates non-existent Enum that existsI’m using the Mono compiler. When I tried to compile this: using static System.Globalization.CharUnicodeInfo; using static System.Globalization.UnicodeCategory; namespace AS3Kit.Lexical { static… 
- 
		3 votes1 answer63 viewsHow to check value in enumerator with [Flags]?I have my enumerator: [Flags] public enum EConta { Receber = 1, Pagar = 2, Cobrada = 3, Atrazada = 4 } and have the assignment EConta conta = EConta.Receber | EConta.Pagar; var retorno =… 
- 
		3 votes1 answer686 viewsHQL query with ENUM list as parameterHello, I have the following problem, follow an example: I have an entity Banda which has as attribute a list of generos List<Generos> generos, Generos is an ENUM with the following values:… 
- 
		3 votes2 answers223 viewsStatic constantsenum Animals { DOG("woof"), CAT("meow"), FISH("burble"); String sound; Animals(String s) { sound = s; } } class TestEnum { static Animals a; public static void main(String[] args) {… 
- 
		3 votes1 answer554 viewsClass or the Enum?I am designing a C# RPG game and found a design decision problem and need help to find the most flexible way to implement the desired. I’ll explain a little bit about the project: There are some… 
- 
		3 votes2 answers277 viewsValue of Enum C#I have a question regarding the following code snippet: public enum TipoPessoa { [System.Xml.Serialization.XmlEnumAttribute("1")] Fisica = 1, [System.Xml.Serialization.XmlEnumAttribute("2")]… 
- 
		3 votes1 answer438 viewsStoring multiple values of an Enum in the databaseI wish I could save several options of an Enum (day of the week) something like 1,3,5 (Monday, Wednesday, Friday) As modeling described here. I created a model public class Horario { [Key] public… 
- 
		3 votes1 answer322 viewsHow big is an "Enum" in C?In general the enum keeps a whole, I can consider that this is the size of it? 
- 
		3 votes1 answer45 viewsEnum class not accepting checkWell I’m having a doubt I’m starting now at C++ I’m using an Enum class: enum class TYPE_ENTER { ENTER_OK = 0x1, ENTER_WARNING = 0x2 }; but when I compile the function there is error C2678 in the… 
- 
		3 votes2 answers621 viewsHow to use Enum.Parse()?My code displays error when using Enum.Parse<enum>(Console.ReadLine()); I am asking the user to enter the level of the position occupied, however to receive the data entered by the user… 
- 
		2 votes1 answer841 viewsConvert Enum variable to int in C#I have the following code: enum type = { OPEN = 0, CLOSED, UNDEFINED}; list<int> frequencia = new list<int>(new int[] {0,0,0}); I would later like to carry out the following operation:… 
- 
		2 votes2 answers1812 viewsWhy compare Enum with an Enum ObjectWhen I was learning Java, I had a Class that had a property like Enum, and, at a certain point, I wondered if what was coming in a Method was equal to a constant of the Enum, something like that:… 
- 
		2 votes1 answer914 viewsPrint Enum field in JasperreportsI created a Enum which has a description field for each of its items. In my report on Jaspersoft Studio i want to print this description field and not the name() of Enum. I created a field in the… 
- 
		2 votes1 answer1126 viewsHow to change values of an Enum within the code itself?What I’m trying to do is, when I call an Enum, and instantiate, it shows up with an X value, and when I’m messing with it in the code, it changes the value to whatever I want. Example: //Classe dos… 
- 
		2 votes1 answer299 viewsHow to display an Enum item on my table using Angularjs?I have a table where I make a ng-repeat, hitherto normal. <tr data-ng-repeat="item in itemsconfiguration"> <td>{{::item.Description}}</td> <td>{{::item.Order}}</td>… 
- 
		2 votes2 answers347 viewsSending Text from an Enum display by JsonGuys, I’ve got an Enum for days of the week, being: Segunda = 2, [Display(Name="Terça")] Terca = 3, Quarta = 4, Quinta = 5, Sexta = 6, [Display(Name = "Sábado")] Sabado = 7 So I build an object that… 
- 
		2 votes1 answer781 viewsDoubt when declaring Enum with stringnumDeclarate an Enum type string, like this: public enum SEXO { M = "Masculino", F = "Feminino" } As I do to have an Enum similar to the one above. That way give error: Cannot implicitly Convert… 
- 
		2 votes1 answer576 viewsIn an MVC project, where should I leave the enums?I am developing a program with MVC standard, I needed to create some enum, and left them in the layer Model, but I was in doubt about its location, which would be the most correct layer to house the… 
- 
		2 votes1 answer156 viewsCan index in an ENUM field bring any advantage?I was reading in a reply from Soen, that the fields of a table that have INDEX can optimize a query. Of course, as long as this query is known, such as a user survey by the email, for example. I… 
- 
		2 votes1 answer83 viewsHow to use an enumerator like Itemsource from a Combobox?Assuming I have the following: enum Dias {Segunda, Terça, Quarta, Quinta, Sexta, Sábado, Domingo}; How can I use the enumerator Dias as ItemSource of a ComboBox in a WPF application? For example:…