enums

Return number of Enum Values. ( Size of Enum typedef )

Is there a built in function or a way to query the size of an emun typedef? typedef enum difficultyTypes { kEasy, kMedium, kHard } difficultyType; I would like a way to query and have it ( in this case ) return 3. I could even deal with it returning 2 as the highest value ( 0,1,2 ). Or am I forced to use another int variable that I s...

GCC says "syntax error before numeric constant" in generated header file from bison.

When I compile my .y file with bison parser.y -d -t and then include the parser.tab.h file in my flex file, gcc says "error: syntax error before numeric constant." It's referencing line 32, which is the first line in the enum of yytokentype. enum yytokentype { BREAK = 258, ... } The error is about the line "BREAK = 258." I hone...

How to Bind Flags Enums To ListBox In MVVM

Hi, I want to bind an enum which has flags attribute to a listbox with a check list box item template in mvvm pattern? How can I do this? [Flags] public enum SportTypes { None = 0, Baseball = 1, Basketball = 2, Football = 4, Handball = 8, Soccer = 16, Volleyball = 32 } <ListBox Name="checkboxList2" ...

question in designing a class in java

I have a Employee class and department class.Now within employee i have a department as its member.The department can be either of 2 type "HR" or "Admin".Now should i declare departmentype as a enum in a separate interface and then should model department class as show below? public interface Myconstants{ enum Depttype{HR,Admin}; } ...

problem in declaring enum

public enum ItemType{REFRENCE,ISSUE}; ItemType itemType = IntemType.ISSUE ; int intemNo=0; I am geting error wheni use above code?why is it so? ...

Problem with designing class

I have a classes as below public class Book extends Item{ ...} public class DVD extends Item{ ...} Book can be of type REFRENCE or ISSUE. DVD can be of type ISSUE only. So should I create Item as follows? public class Item { public enum ItemType{REFRENCE,ISSUE}; ItemType itemtype; } Or I should declare seperate enum for bot...

Are there any java Enum of european countries and languages ?

Hi there ! Is there any java (>5) enum for listing european countries and languages somewhere ? If there aren't any, I'll probably write them from this list : http://www.nationsonline.org/oneworld/european_languages.htm But if I could avoid that burden, that would be great ! Thanks in advance ! Philippe P.S. : Finally, I'm starting t...

C++: Using enum as template type argument

Hi, are there any restrictions / problems using an enum as template (type) argument in C++? Example: enum MyEnum { A, B, C, D, E }; template <typename _t> class MyTemplate { public: _t value; void func(const _t& param) { /* .... */ } }; // .... MyTemplate<MyEnum> MyInstance; My actual problem using MSVC++ via VS 2008...

How can I convert an enumeration into a List<SelectListItem>?

i have an asp.net-mvc webpage and i want to show a dropdown list that is based off an enum. I want to show the text of each enum item and the id being the int value that the enum is associated with. Is there any elegant way of doing this conversion? ...

Is it possible to define an enum in C# with values that are keywords?

I have some client data that I am reading in, and I've defined an Enum for one of the values, so I can use Enum.Parse(type, somestring). The problem is they just added a new value: "public". Is it possible to define an enum value that is also a reserved word? I.E.: public enum MyEnum { SomeVal, SomeOtherVal, public, Y...

Using special character in Enum e.g. % (C#3.0)

I ahve a combo whose source is an Enum. Now , among the other values(say value1, value2 etc.) there is one item Changes(%) that will be displayed in the combo . How to define Changes(%) in the enum? Using C#3.0 Thanks ...

Enums with string values and finding enum by value

Hi, I want to have an enum like the following and then have a method something like Util.FindFruitByValue("A") which returns the enum Apple. this is because the abbreviations are stored in database and I need to convert them to appropriate enums after reading from db. is this possible OR do I need to create a separate class for it? Pleas...

What type should I use for binary representation of C enum?

As I know C enum is unsigned integer, but this may vary by implementation. What type should I use for the enum in binary representation? *PS 'binary representation' means byte-array. I want to serialize enum values to socket to inter-operate with other programs. ...

using enum in a class?

public Car{ public enum Color{RED,BLUE}; private Color color; Car(Car.Color c) { this.color =c } } is it the correct way? ...

What's the data-type of C enum of Clang compiler?

I posted other question: http://stackoverflow.com/questions/3509470/what-type-should-i-use-for-binary-representation-of-c-enum, and by the answer, I have to know my compiler's enum data-type. What's the data-type of C enum on Clang compiler? ...

How to have an enum value in CommandParam in XAML

I have the following enum that represent a state of UI (I use it to enable and disable UI elements): enum Mode { EDIT, RUN, REVIEW } I would like to pass Mode.EDIT to command in CommandParam: <Button Grid.Column="6" VerticalAlignment="Top Command="{Binding Path=ChangeMode}" CommandParameter="{StaticResource local:Mode.RUN}" /...

What is main use of Enumeration ?

What is main use of Enumeration in c#? Edited:- suppose I want to compare the string variable with the any enumeration item then how i can do this in c# ? ...

Simulate a class of type enum

Hello, how can I do to simulate a class of type enum in java <5.0 ..?? public final class Week { private static final Day[] _week = {Day.MONDAY, Day.TUESDAY, Day.WEDNESDAY, Day.THURSDAY, Day.FRIDAY, Day.SATURDAY, Day.SUNDAY}; public static Day getDayOfWeek(final int index) { if (index >= 1 && index <= 7) { ...

Enum.TryParse not supporting in vs2008 in c#

Enum.TryParse(,,out) not supporting in vs2008 in c#? why? I am trying to use but getting error that TryParse no defined. ...

What would be the best way to wrap an enum

I have my enum, which I don't want to share between layers. So I was thinking wrapping it up would be neat. But how ? There are many items, manualy writing down all items isn't a solution. Also the enum is getting generated. I'd like to keep the intelisense. ...