Linked Questions

23 votes
4 answers
14k views

I have an enumeration like Enum Complexity { NotSoComplex, LittleComplex, Complex, VeryComplex } And I want to use it in a dropdown list, but don't want to see such Camel names in list (...
bzamfir's user avatar
  • 4,926
5 votes
2 answers
14k views

I have this enumeration Public Enum Applications Unknown = 0 AA = 1 BB = 2 CC = 3 End Enum Private Const CALLING_APP As Applications= Applications.CC CALLING_APP.ToString() is ...
Pratap Das's user avatar
1 vote
0 answers
3k views

I have an enum like this: public enum MyEnum { people1, people2 } I want to override or overload ToString() method. For example in the following code, variable s becomes "This is people 1". ...
mohammad's user avatar
  • 1,318
0 votes
1 answer
751 views

have this class: public static class Command { public const string SET_STB_MEDIA_CTRL = "SET STB MEDIA CTRL "; public static string ECHO = "ECHO"; public static string SET_CHANNEL = "SET ...
petrtim's user avatar
  • 287
1 vote
1 answer
93 views

I want to create a select option in Razor pages from Enum object Description This is my code: <div class="dropdown-box"> <select id="type-select"> @foreach (...
Muhammad Ashouri's user avatar
142 votes
21 answers
93k views

In the post Enum ToString, a method is described to use the custom attribute DescriptionAttribute like this: Enum HowNice { [Description("Really Nice")] ReallyNice, [Description("Kinda Nice")] ...
Shalom Craimer's user avatar
129 votes
16 answers
131k views

It's easy to get the value of a key from a .NET generic Dictionary: Dictionary<int, string> greek = new Dictionary<int, string>(); greek.Add(1, "Alpha"); greek.Add(2, "Beta"); string ...
Dour High Arch's user avatar
76 votes
25 answers
8k views

We noticed that lots of bugs in our software developed in C# (or Java) cause a NullReferenceException. Is there a reason why "null" has even been included in the language? After all, if there were ...
sthiers's user avatar
  • 3,531
30 votes
4 answers
44k views

Is it ok to use a class like this (design / guideline specific)? I'm using MVVM Pattern. public static class Pages { public const string Home = "Home.xaml"; public const string View2 = "View2....
SBoss's user avatar
  • 9,305
24 votes
3 answers
17k views

I would like to have an explicit cast between from a string to an enum in c# in order to have this : (MyEnum) Enum.Parse(typeof(MyEnum),stringValue) I would like to deport this into an explicit cast ...
Boris Gougeon's user avatar
19 votes
5 answers
17k views

Say I have an enum something like: enum OrderStatus { AwaitingAuthorization, InProduction, AwaitingDespatch } I've also created an extension method on my enum to tidy up the displayed ...
fearofawhackplanet's user avatar
19 votes
3 answers
11k views

I found a good looking example about implementation enums in a different way. That is called type-safe enum pattern I think. I started using it but I realized that I can not use it in a switch ...
Fer's user avatar
  • 2,002
4 votes
4 answers
17k views

HI I have the following enum public enum Priority : byte { A=1, B+ = 2, B=4, C=8, D=16, E=32 } I want to add B+ in the enum but it is giving ...
Tassadaque's user avatar
  • 8,197
9 votes
3 answers
24k views

It says here that the possible types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong. What if I need a float or a double to define percentage increments such as 1.5 or 2.5 for ...
user310291's user avatar
  • 38.6k
21 votes
2 answers
12k views

This is probably best shown with an example. I have an enum with attributes: public enum MyEnum { [CustomInfo("This is a custom attrib")] None = 0, [CustomInfo("This is another attrib")]...
Keith's user avatar
  • 157k

15 30 50 per page
1
2 3 4 5