enums

Using NHibernate to map a nChar column to an enumerated type

Hello Folks, I am trying to map a table frp, a SQL Server 2005 DB to a class which contains an enum: public class MyClass{ private YesNoOptional addressSetting; public YesNoOptional AddressSetting{ {get; set;} } } public enum YesNoOptional { Yes, No, Optional } This will dictate that one of three values is inserte...

Business enum to DatContract Enum conversion in WCF

I have an enum namespace Business { public enum Color { Red,Green,Blue } } namespace DataContract { [DataContract] public enum Color { [EnumMember] Red, [EnumMember] Green, [EnumMember] Blue } } I have the same enum as a datacontract in WCF with same values. ...

Entlib validation to syntax to accept only numeric month numbers?

I've got an enum defined as such: Private Enum AllowedMonthNumbers _1 _2 _3 _4 _5 _6 _7 _8 _9 _10 _11 _12 End Enum Then a property validator defined as: <TypeConversionValidator(GetType(Int32), MessageTemplate:="Card expiry month must be numeric.", Ruleset:="CreditCard")> _ <EnumConver...

enums in C# - assignment

How does one do this in c#? Let's say that myclass has : private enum Days{}; 1) How does one add data to the enum inside the myclass with the help of the constructor? As in : myclass my = new myclass(Monday,Friday); so that the enum inside the class gets the "Monday, Friday" properties. 2) Can one also make a property for a...

How do I implement this public accesible enum

Hey guys, I'm trying to access my class's private enum. But I don't understand the difference needed to get it working compared to other members; If this works: private double dblDbl = 2; //misc code public double getDblDbl{ get{ return dblDbl; } } Why can I not do it with enum? private enum myEnum{ Alpha, Beta}; //misc code ...

show enum in view

i have enum public enum TypeImage { Img=0, Thumb=1 } i want in view show <%= TypeImage.Img %> -it shows "img" but not 0. what the problem? ...

Logic inside an enum

My colleagues and I were having a discussion regarding logic in enums. My personal preference is to not have any sort of logic in Java enums (although Java provides the ability to do that). The discussion in this cased centered around having a convenience method inside the enum that returned a map: public enum PackageType { Letter("01...

Winforms Bind Enum to Radio Buttons

If I have three radio buttons, what is the best way to bind them to an enum which has the same choices? e.g. [] Choice 1 [] Choice 2 [] Choice 3 public enum MyChoices { Choice1, Choice2, Choice3 } ...

Loop on enumeration values

How awful is it - or is it perfectly acceptable - to index a loop on an enumeration? I have an enumeration defined. The values of the literals are default values. The assigned values do not have any significance, will not have any significance, and the values of any literals added in the future will also not have any significance. It's ...

Enum as a Parameter in Dynamics AX

My report has a parameter which uses a base enum. The enum has 4 different options to choose when running the report. How do I insert an option which uses all 4 at once? For example, I have an enum named Phone and it has 4 types: 1 = None, 2 = Home, 3 = Mobile, 4 = Work. In a drop down, how do I add option 5 = None+Home+Mobile+Work? T...

Wpf ListViewItem Background binding to enum

Hi Guys I´ve got a ListView which is bound to the ObservableCollection mPersonList. The Class Person got an enum Sex. What i want to do is to set the background of the ListViewItem to green if the person is male and to red if the person is female. Thanks for the answers! i tried it like this but whats wrong with it? <Style x:Key="Cust...

C# Enum List/Collection on User/Web Control design time support?

I've been banging my head against a brick wall over this little problem since thursday and I'm still no nearer to an answer than I was back then. I have a user control which has a property like this: /// <summary> /// Gets or sets the media types. /// </summary> /// <value>The media types.</value> public List<MediaType> MediaTypesFilte...

how to create a static enum with a value that has a hyphen symbol in java?

Hi, how to create the static enum like below static enum Test{ employee-id, employeeCode } as of now, i am getting error. ...

Implementing toString on Java enums

Hello It seems to be possible in Java to write something like this: private enum TrafficLight { RED, GREEN; public String toString() { return //what should I return here if I want to return //"abc" when red and "def" when green? } } Now, I'd like to know if it possible to returnin the toSt...

What can I do with an enum variable?

When I declare a enum variable like this: enum paint_colors { RED, GREEN, BLUE, ...} colors; is the colors variable useful? If so, what can I do with it? Thanks in advance. ...

Declaring an enum within a class

In the following code snippet, the Color enum is declared within the Car class in order to limit the scope of the enum and to try not to "pollute" the global namespace. class Car { public: enum Color { RED, BLUE, WHITE }; void SetColor( Car::Color color ) { _color = color; } Car::Color Get...

Java enums: Gathering info from another enums

I made a similar question a few days ago, but now I have new requirements, and new challenges =). As usual, I'm using the animal enums for didactic purposes, once I don't want to explain domain-specific stuff I have a basic enum of animals, which is used by the whole zoo (I can add stuff to it, but must keep compatibility): public enum...

How would I best address this object type heirachy? Some kind of enum heirarchy?

I'm curious as to any solutions out there for addressing object heirarchies in an ORM approach (in this instance, using Entity Framework 4). I'm working through some docs on EF4 and trying to apply it to a simple inventory tracking program. The possible types for inventory to fall into are as follows: INVENTORY ITEM TYPES: Hardware P...

enum associated values in c

I have an enum declaration as: enum qty { cars = 10, bikes = 9, horses = 9 ... } // total 28 How could I add up all the associated values of enumerator-list? ...

Possible to load an Enum based on a string name?

OK, I don't think the title says it right... but here goes: I have a class with about 40 Enums in it. i.e: Class Hoohoo { public enum aaa : short { a = 0, b = 3 } public enum bbb : short { a = 0, b = 3 } public enum ccc : short { a...