Linked Questions

27 votes
6 answers
14k views

What's the equivalent of Java's enum in C#?
Nosrama's user avatar
  • 15k
0 votes
2 answers
3k views

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 ...
Spedwards's user avatar
  • 4,510
0 votes
1 answer
179 views

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"); ...
JoeKalango's user avatar
0 votes
1 answer
149 views

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....
user1188867's user avatar
  • 3,998
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
79 votes
4 answers
80k views

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. ...
Sylvain Rodrigue's user avatar
33 votes
6 answers
90k views

in java im used to extending enum values or overriding methods like this : enum SomeEnum { option1("sv") { public String toString() { ...
Chris McGrath's user avatar
4 votes
2 answers
10k views

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 ...
Alan Wayne's user avatar
  • 5,424
1 vote
3 answers
3k views

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("...
RRR's user avatar
  • 4,203
6 votes
3 answers
3k views

I'm creating a flags enumeration in C#, similar to the following: [Flags] public enum DriversLicenseFlags { None = 0, Suspended = 1 << 1, Revoked = 1 <&...
Scott Wegner's user avatar
  • 7,543
1 vote
3 answers
2k views

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), ; ...
Roland's user avatar
  • 18.5k
2 votes
2 answers
3k views

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= ...
David's user avatar
  • 127
0 votes
3 answers
2k views

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, ...
Bassem's user avatar
  • 4,180
0 votes
1 answer
2k views

enum class CoffeeStrength { LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5 }
DARAKA's user avatar
  • 13
3 votes
1 answer
2k views

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-...
soapygopher's user avatar

15 30 50 per page