A data type consisting of a set of named values called elements, members or enumerators of the type.

learn more… | top users | synonyms

0
votes
1answer
33 views

Improving Design for structured Keys

On several occasions I had to use a fixed set of keys (constants in the sense of static final String) with some additional logic (grouping in different keySets). After some more or less lefthanded ...
1
vote
1answer
38 views

One method for changing one of the properties C#

I have a few resources set in my class – coins, diamonds, hearts, enum of these resources names, and method for increasing specified resource. I want to make single "Increase" method for all resources ...
6
votes
1answer
53 views

Method that returns description attribute of enum value

I have the following method in .NET Core that returns the description attribute of an enum value. I think this code can be more elegant. I'd appreciate some ...
1
vote
1answer
43 views

Use predefined vs. custom enums to return appropriate message from service layer [closed]

In my project I used N Layer Architecture. In the service layer I return an enum for each action, for example for Add action ...
3
votes
0answers
31 views

ByteUnit class to convert across size units

Based on java.util.concurrent.TimeUnit class I wrote similar class to convert size units: ...
8
votes
5answers
240 views

Validate input that maps int to enum

I've written the following enum and have added a function, fromValue that allows the caller to map given int into the enum value. I was wondering if the ...
1
vote
1answer
81 views

Enum of calculator operations

I'm making my first simple project which I decided would be a calculator and I'm kind of stuck on implementing the operations. I have two classes one of which is the GUI part and the other one ...
3
votes
3answers
125 views

Enum wrapped in a struct

I was thinking about how I was going to use some enums I made, how I was going to make sure they had valid values and how to call the class which would contain the necessary extensions methods. And ...
7
votes
4answers
985 views

Storing Enum values as Strings in DB

I have a Data First Migration and have been struggling a little with storing an enum value as a string. (Im aware that enums should be stored as ints but, personally I have never liked this, yes ...
1
vote
0answers
102 views

Enumerations with Binary keys

I created a simple module, that is used to work as Enumeration. It can store all values with binary keys, so you can find them using binary pattern. It's called grouping. Groups have the same ...
5
votes
3answers
218 views

Select the Enum to classify a string based on the first word found

I have written a small function that will check a string to see if it contains a certain word. Depending on the word that is found first, the function will return the correct Enum value that needs to ...
2
votes
1answer
48 views

Calling an appropriate enum method depending on what type is passed

I have this Enum from which I am calling the appropriate execute method based on what type of enum (eventType) is passed. ...
1
vote
1answer
49 views

SafeBox StateMachine implemented with Enums

does someone has any opinions about this SafeBox StateMachine? ...
5
votes
1answer
119 views

Test and implementation of a reorderable data structure that stores number of users (classifiable as per gender, country, etc.) of an Application

I have implemented a data structure that allows storage of number of users of a hypothetical application in a tree-like data structure in nodes as per their classification based on categories such as ...
3
votes
1answer
43 views

Enum as state for log parsing

I have a small project to help me analyze query latency from PostgreSQL statement logging. It's my first time writing anything real in Rust and I think it could be improved in several ways. My ...
1
vote
2answers
123 views

Filtering a list by comparing enums against a user choice

I have a list of objects where one of the properties on the object class is an enum. The program below simply loops through each item in the list, checks an int value, then checks the enum value for ...
3
votes
2answers
59 views

Building a summary string from a flags enum

I'm trying to replicate the attributes text that appears in File Explorer, for files and directories. I can't just use the enum names, as the summary text uses a single character for each set flag, ...
4
votes
3answers
134 views

Setting enum flags by string (in any order)

I want to set flags which are given in string representation in any order. And it is intimidating, because you have to check like 2^3 possible options in my occassion. I was just wondering is there ...
4
votes
1answer
74 views

Getting enum values of Pseudo-Enum classes

By "Pseudo-Enum" classes I mean cases where someone's used a class with public static properties to emulate enum behaviour; e.g. as described here. Per the example below, this is useful for classes ...
1
vote
0answers
33 views

Templated string to enum mapping code

I'm trying to create series of template classes that I can use to simplify the process of adding string to enum mapping support. The goal is to minimize the amount of code I have to repeat to define ...
4
votes
1answer
64 views

Enumerations via reflection in AS3

I'm very much used to enumerations a la Java, where each value in an enum is a distinct object. You can call functions on these objects, and they're generally ...
5
votes
1answer
223 views

Localized Enum in C# 6

I had to jump through some hoops to get a localized enum working. I went through dozens of SO articles that never actually answered the relevant conundrum with a working solution. So I made my own: I ...
6
votes
3answers
107 views

Parsing excel cells containing line feed characters

This is a direct follow up to Parsing cells containing Line Feed Characters. Link to sanitized xls on dropbox if test data is needed Essentially the reports I work with aren't bad - The issue is ...
1
vote
1answer
68 views

Switch statement to build context menu (with many redundant lines of code)

I have switch statement that is switching on an enum to build a ContextMenu depending on ...
5
votes
2answers
142 views

Scrabble Tile Counter

Introduction Inspired by this r/dailyprogrammer problem, I've written a Scrabble tile counter. Given a Collection of Scrabble tiles known to be in play, it can ...
2
votes
1answer
107 views

Weightlifting calculator

I'm building a simple iOS app using Swift that calculates the One Rep Max weight a user can theoretically lift. User inputs a weight lifted, the number of repetitions and the app uses one of several ...
2
votes
2answers
93 views

Function to compare objects based on type enums

I'm looking for a better way to implement a huge CompareTo function that relies on an Enum to perform sorting. The data structure is essentially a flattened Multi Level Group. Any ideas and concept to ...
3
votes
1answer
210 views

Enum string parse and get custom attribute assign to array

I wrote a code which: - parse string to my enum - get description from enum - assign to string[] array ...
3
votes
1answer
147 views

Add Field To PDF with Options for Multiple Pages

This is related to here and here. These two methods are used to programatically add a text field to a PDF document. The field can be of any user determined size and have any user determined title, and ...
2
votes
1answer
317 views

Rails validating enum

The Ruby on Rails framework doesn't allow you to validate enums submitted through a form in any sane manner. Evidently, enums are meant to be used to maintain internal application state, and are not ...
7
votes
1answer
112 views

Building a string representing 50+ ActiveDirectory options

I have a switch statement used to handle options that a user selected (stored in an array). The array is iterated through, and for each element (enum object) in the array, an appropriate action is ...
4
votes
0answers
50 views

Implementing a StringEnum

This is to be used like an Enum (as parameter mostly), but for string (Using .NET 3.5) Actual implementation: ...
2
votes
2answers
96 views

Enum for converting between field naming conventions

Based on this question and this answer, I decided to try the enum approach to do some more conversions I need in my application. This time I required to convert between the different field naming ...
3
votes
0answers
234 views

Enum to string with template metaprogramming

This allows enum values to be outputted as strings. But enum_strings is a type, not a map or a vector, so if the enum value is known during compile time, there ...
3
votes
2answers
194 views

Operator-based switch for a database query filter

I am currently working on a method, that can search based on a value and an operator. Currently I check which operator was supplied to the the method in a switch, and do operations accordingly to it. ...
8
votes
4answers
2k views

Selecting an enum for a payment transaction

I'm writing a small Android application that deals with payments and, in my function that handles transactions, I need to translate a number of installments (1-12) and whether or not it has interest (...
4
votes
3answers
261 views

Using Enum to Handle String literals

I have a java component that was using a lot of string literals that I need to make comparisons on and return booleans based on these comparisons. In order to make the code more robust I externalized ...
2
votes
1answer
99 views

Poker app in C#

I am developing a poker application using C#. It is almost done, and I'm looking for improvements. One of the things I wonder is whether I should change my method that checks if the player has a flush....
1
vote
1answer
56 views

Single Flag Only Enum (RestrictedEnum<T>)

This class simply allows you to use an enum while only allowing you to set a single flag. If multiple flags are set they will be rejected--unless the total of the combined flags is the same value of ...
2
votes
1answer
84 views

Basic JSON Representation in Rust

This week I started reading "The Rust Programming Language". As I reached the chapters on enumerations and pattern matching I felt I had enough material to put together a simple representation of JSON ...
3
votes
3answers
74 views

Avoiding numbness with Python Enum

First, the context: I'm working with a student to build a web frontend for a star cluster simulation package called starlab. Typical starlab usage involves ...
-2
votes
1answer
122 views

Enum Singleton implementation in Java

I just wanted to implement the enum singleton in java. Here is my implementation where I have tried to create a singleton DataSource instance: ...
6
votes
1answer
79 views

A global Enum for comparison operators

This approach was born out of wanting to pass a logical expression (E.G. ">=10000") as a parameter to a function. So, I built an Enum and a function to use it to evaluate logical expressions. Is ...
9
votes
4answers
1k views

Flags on steroids

What is so bad about [Flags] enum? It does not support IEnumerable<T> anyhow, so to get one we need to use syntax like (...
2
votes
1answer
58 views

Comparing a selected attribute of a color with a given value

I need to call different functions depending on which enum value is used as parameter. it's working as it should do, but I wanted to ask if there's a proper way to do this without lacking a good ...
6
votes
2answers
213 views

Efficiently return a ChatColor

I am working on a plugin for a Minecraft server. In it, I have a function that returns a ChatColor depending on what permission level you are. Whenever I need ...
12
votes
2answers
2k views

Extension method to list enum values

I have the following enum extension method: ...
5
votes
2answers
122 views

Enums for the four directions

I have walls that I can spawn. They wll move in one of four directions, up, down, right or left. Now I can set, wether the wall is thin, wide, long or short, but the problem is: Nearly everything I ...
2
votes
2answers
870 views

Parsing from one enum to another

I face a problem I think I am not approaching appropiately. I have two independent enumerators that both will contain the same members, the only difference being the values given. I have to be able ...
0
votes
1answer
743 views

Remove elements existing in a list built from an enum

The objective of this code is to make the difference inbetween two lists of items, that is knowing which items are missing in the second list in regards to the first one. The first list is built from ...