enums

MYSQL: How to get enum element from index

I have a select in which I do a "group by". One of the columns is an enum, and I want to select the biggest value for each group (i.e the one with the largest index in the enum). I can do select MAX(enum_column+0) as enum_index to get the the largest index in the group, but how can I turn the enum index back to the enum item? Exam...

enum name with multiple values

In my project i'm using enums example: public enum NcStepType { Start = 1, Stop = 3, Normal = 2 } i'm reading values from a database, but sometimes there are 0-values in my record, so i want an enum that looks like public enum NcStepType { Start = 1 OR 0, Stop = 3, Normal = 2 } is this possible (in c#) ? ...

Size reduction for enum storage in Fujitsu Softune

Fujitsu microcontroller used is 32bit. Hence enum storage is also 32bit. But in my project actually enum elements do not exceed more than 256. Is there any compiler options to size down the storage for enums? ...

Nhibernate's EnumStringType and Oracle

Hi, I'm using an EnumStringType in my mapping to insert the enum string value in my DB. The problem is that Oracle needs AnsiString type for their parameters, and the EnumStringType maps the parameter values to "normal" String types. Something that got me busy for days until I found this article of James Kovacs Which means, that currentl...

Enum.GetValues() Return Type

I have read documentation that states that ‘given the type of the enum, the GetValues() method of System.Enum will return an array of the given enum's base type’ ie int, byte etc However I have been using the GetValues method and all I keep getting back is an array of type Enums. Am I missing something?? public enum Response { Yes...

Convert a DevExpress TcxFilterOperatorKind to and from a string ?

Hi! Here is a codesnippet I use to get filtertype operator from a filter in a DevExpress grid: OperatorKindToStr is used to extract operatorkind from a filter as string and store it in a xml-file. StrToOperatorKind is used to convert back a string from xml to set an operatorkind in a filter. const CUSTFILTER_FILTERITEM = 'FilterI...

Enum Naming Convention - Plural

I'm asking this question despite having read similar but not exactly what I want at http://stackoverflow.com/questions/495051/c-naming-convention-for-enum-and-matching-property I found I have a tendency to name enums in plural and then 'use' them as singular, example: public enum EntityTypes { Type1, Type2 } public class SomeClass {...

C# enum display on Expression.ToString()

Hello, When I call the ToString() methods on an expression, the enum value are printed as integers. Is there some format overload ? Maybe I can create an derviedclass from expression and override some ToString Method. Any thoughts ? Here is a sample : public enum LengthUnits { METRES, FEET }; Expression<Func<LengthUnits, bo...

Why use flags+bitmasks rather than a series of booleans?

Given a case where I have an object that may be in one or more true/false states, I've always been a little fuzzy on why programmers frequently use flags+bitmasks instead of just using several boolean values. It's all over the .NET framework. Not sure if this is the best example, but the .NET framework has the following: public enum...

Comparing two enum *types* for equivalence?

In my application, I have two equivalent enums. One lives in the DAL, the other in the service contract layer. They have the same name (but are in different namespaces), and should have the same members and values. I'd like to write a unit test that enforces this. So far, I've got the following: public static class EnumAssert { pub...

Hidden field to store the int representation of an enumerated value

I'm a total asp.net newbie just fixing a bug in some code. I want a hidden field that displays the integer representation of a enum. Currently the following line displays the "Text" / human readable version of the enum. <asp:Label ID="lblNoteType" runat="server" Text='<%# Bind("NoteType") %>'></asp:Label> What do I need to do to the...

Java extend enum

Is something like this possible in Java. I want to take an existing enum and add more elements to it enum A {a,b,c} enum B extends A {d} /*B is {a,b,c,d}*/ ...

C# Enums - can my enums have friendly names?

I have the following enum public enum myEnum { ThisNameWorks, This Name doesn't work Neither.does.this; } Is it not possible to have enums with "friendly names" ? Thanks ...

Enums And WCF - Meaningful Error?

I'm trying to overcome a problem with WCF and enums, where I'm trying to pass an object from the server to the client (or another server), which contains an enum. The enum starts with 1, on purpose. Everything goes fine when the enum is initialized and when the value is defined in it, but when it's not defined in the enum, I get this won...

Understanding Enums in Java

What are java enums? How do they work? Where could I used them and how? Can I do without using enums in an app or are they so powerful that Its better to use them than ignore them? ...

Why do I get "type has no typeinfo" error with an enum type

I have declared the following enum type in which I want the first member to have the ordinal value of 1 (one) rather than the usual 0 (zero): type TMyEnum = ( meFirstValue = 1, meSecondValue, meThirdValue ); If I call TypeInfo(), e.g. as part of a call to GetEnumName(), ...

C# How to display Dataset's Byte column as an Enum in MS Reporting Services?

Hi. How to display an Enumeration Value in Microsoft reporting based on the byte column from a DataTable? I want to cast =Fields!Status.Value to something like (MyEnum)Fields!Status.Value and then call .ToString() on it. Status is a Byte type. ...

c# enums: can they take members and functions like java enums?

hello, in java it is possible to give an enum a constructor as well as member variables and functions. i was wondering if something like this is possible in c# enums as well. if so, how? thanks a lot! ...

Parse string to enum type

I have an enum type like this as an example: public Enum MyEnum { enum1, enum2, enum3 }; I'll read a string from config file. What I need it to parse the string to MyEnum type or null o not defined. Not sure if the following codes will work (sorry for not having access to my VS right now): // example: ParseEnum<MyEnum>("ENUM1", r...

Is this way of using Dictionary<enum,object> correct in this Production Planning example?

Consider a production planning application with many products. Each product has a list of InventoryControl objects keyed on InventoryControlType. Depending on the algorithm we run for production planning, we need to access to different types of InventoryControl objects for a given product. This works OK. However, today I needed to introd...