Linked Questions
26 questions linked to/from C# vs Java Enum (for those new to C#)
27 votes
6 answers
14k views
What's the equivalent of Java's enum in C#? [duplicate]
What's the equivalent of Java's enum in C#?
0 votes
2 answers
3k views
Advanced Enumerations in C# [duplicate]
So I am working with Enumerations for my first time in C# but I don't think it'll last as I just realised the lack of flexibility you have with them as you do in Java. For example, the equivalent of ...
0 votes
1 answer
179 views
Enums in Java VS Enums in C# [duplicate]
I have a very basic question. In Java, it is possible to point attributes and variables to Enums, such as: public enum DayTime{ Morning("Morning"), Afternoon("Afternoon"), Night("Night"); ...
0 votes
1 answer
149 views
How to maintain interlink between multiple enums in c# [duplicate]
I'm new to c#, in java we used to have interlinking for enums like below: public enum Module { None(SubModule.None), Authentication(SubModule.Login), User(SubModule.User,SubModule....
600 votes
29 answers
451k views
Getting attributes of Enum's value
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 ...
79 votes
4 answers
80k views
Private inner classes in C# - why aren't they used more often?
I am relatively new to C# and each time I begin to work on a C# project (I only worked on nearly mature projects in C#) I wonder why there are no inner classes? Maybe I don't understand their goal. ...
33 votes
6 answers
90k views
Extending enums in c#
in java im used to extending enum values or overriding methods like this : enum SomeEnum { option1("sv") { public String toString() { ...
4 votes
2 answers
10k views
How to declare an Enum to be used by a generic type?
I would like to declare in a parent abstract class something along the lines of: public abstract void RefreshDisplay<TView>(Enum value); Which would then be implemented in the child class ...
1 vote
3 answers
3k views
DefaultValue Attribute in C#
I want to use on DefaultValue Attribute to define default value for custom class that I write in my App. the class gives in his constractor a string. I write the follow: [DefaultValue(Type.GetType("...
6 votes
3 answers
3k views
Private value in C# flags enumeration
I'm creating a flags enumeration in C#, similar to the following: [Flags] public enum DriversLicenseFlags { None = 0, Suspended = 1 << 1, Revoked = 1 <&...
1 vote
3 answers
2k views
Enum with parameters
Is it possible in C# to collect information in an enum instead of a dedicated class? Example how it would work in Java: public enum Action { JUMP( "JUMP", 1), CROUCH ("CROUCH", 2), ; ...
2 votes
2 answers
3k views
EnumSet in c# when there is needed a groupation on levels
In java I have : public enum MyEnum{ Value1, Value2, Value3, //so on } And a class which will have a property : public abstract class MyClass{ public EnumSet<MyEnum> myEnum= ...
0 votes
3 answers
2k views
How to create Class-based Enums in Javascript/Typescript
I have this python code that I'm trying to convert to Javascript/Typescript import enum class Shape(enum.Enum): RECTANGLE = 0 CIRCLE = 1 TRIANGLE = 2 OTHER = 3 print(isinstance(data, ...
0 votes
1 answer
2k views
In kotlin enum default starting order is 0, how can i change it? [closed]
enum class CoffeeStrength { LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5 }
3 votes
1 answer
2k views
How should I model static reference data with Entity Framework?
I have a simulation model that uses a database to store both input and output data, using Entity Framework and the Database First approach. The database is queried through a data access layer more-or-...