Hi everyone,
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:
enum FunkyAttributesEnum
{
[Description("Name With Spaces1")]
NameWithoutSpaces1,
[Description("Name With Spaces2")]
NameWithoutSpaces2
}
What I want is given the enu...
I've encountered this situation so many times...
enum Fruit {
Apple,
Banana,
Pear,
Tomato
};
Now I have Fruit f; // banana and I want to go from f to the string "Banana"; or I have string s = "Banana" and from that I want to go to Banana // enum value or int.
So far I've been doing this.. Assuming the enum is in Fruit.h:
/...
Is there any reason why enums in Java cannot be cloned?
The manual states that
This guarantees that enums are never cloned, which is necessary to preserve their "singleton" status.
But returning the instance itself would also preserve its status, and I would be able to handle associated enums the same way as other clonable objec...
Is there a way in C++ to extend/"inherit" enums?
I.E:
enum Enum {A,B,C};
enum EnumEx : public Enum {D,E,F};
or at least define a conversion between them?
...
I have the following code, where ApplicationType is an enum. I have the same repeated code (everything except the parameter types) on many other enums. Whats the best way to consolidate this code?
private static string GetSelected(ApplicationType type_, ApplicationType checkedType_)
{
if (type_ == checkedType_)
{
...
If int is synonymous to Int32 why does
enum MyEnum : Int32
{
Value = 1
}
...not compile? Where as
enum MyEnum : int
{
Value = 1
}
will, even though hovering the cursor over the int word will display struct System.Int32?
...
i need to populate a table column which takes one of 30 different string values. Is it advisable to use enum here for speed up processing . Can anyone suggest better solution which is reasonably optimum for storage and processing(comparison)?
...
Hi I'm having trouble trying to generalize a function I've written for an specific enum:
public static enum InstrumentType {
SPOT {
public String toString() {
return "MKP";
}
},
VOLATILITY {
public String toString() {
return "VOL";
}
};
public static Instrumen...
I'm trying to use the code from this article: Creating Fake Enums, but I can't figure out why it doesn't work.
This code:
Console.WriteLine(FakeEnum.One.FriendlyName);
Console.WriteLine(FakeEnum.Four.FriendlyName);
generates an exception:
System.TypeInitializationException was unhandled
Message="The type initializer for 'FakeEnum'...
When do Enumerations break down?
To support a new feature in an existing system, I was just considering implementing some form of discriminator to an entity table in my database schema.
In wanting to begin by doing the least thing that will work I first of all decided on an integer column and a C# enum at the business entity layer fo...
At a high level my question is like the following -
I am doing a data sync, using web services, between two different systems. To validate the mater data, I depended on creating enums and tried to validate; which I though will ease my job of comparison. But evetually, I ended up comparing as enum.ToString() (which I feel not a good pra...
Assuming you have a hypothetical enum in java like this (purely for demonstration purposes, this isn't code i'm seriously expecting to use):
enum Example{
FIRST,
SECOND,
THIRD,
...
LAST;
}
What's the maximum number of members you could have inside that enum before the compiler stops you?
Secondly, is there any per...
Hi!, we have a debate about a BEST PRACTISE from a .NET architecture DESIGN POINT OF VIEW:
Task: How to manage role based visibility in UI with enum?
For example: I want to show all team types [a,b,c,d,e] to administrator but only team types [a,b,c] to normal user.
First I have enum which includes all team types:
public enum TeamTyp...
I need to provide a user a list of all primitive types available and was wondering if there is an Enum in the .net library that has all primitive types, so that I don't have to build one.
...
I have created a custom data type enum like so:
create type "bnfunctionstype" as enum ( 'normal', 'library', 'import', 'thunk', 'adjustor_thunk' );
From an external data source I get integers in the range [0,4]. I'd like to convert these integers to their corresponding enum values. How can I do this? I'm using PostgreSQL 8.4.
...
I am writing my first large Scala program. In the Java equivalent, I have an enum that contains labels and tooltips for my UI controls:
public enum ControlText {
CANCEL_BUTTON("Cancel", "Cancel the changes and dismiss the dialog"),
OK_BUTTON("OK", "Save the changes and dismiss the dialog"),
// ...
;
private final String contr...
Here's my problem: I have an object that's referencing a DLL. I would like other objects to reference my object, without having to also include a reference to the DLL itself.
This is fine for the most part except there is an enum in the DLL that I would like to replicate. I could write out the enum line by line, but I'm wondering if the...
I've noticed enums introduce many additional class files (Class$1) after compilation bloating the total size. It seems to be attached to every class that even uses an enum, and these are often duplicated.
Why does this occur and is there a way to prevent this without removing the enum.
(Reason for question is space is at a premium for ...
Previously I've defined enumerated types that are intended to be private in the header file of the class.
private:
enum foo { a, b, c };
However, I don't want the details of the enum exposed anymore. Is defining the enum in the implementation similar to defining class invariants?
const int ClassA::bar = 3;
enum ClassA::foo { a, b, ...
I tend to use enums to create mini data tables all over my code. I use this pattern often. Often enough that I thought I'd ask for others opinion. I'm just curious if I'm taking enums too far, or if I should be doing something else instead.
A common example is an enum I'll use to drive the TableFormat(from glazed lists) in a JXTable(fro...