enums

In VS2010, how to get VB.NET enum values to autocomplete without typing the enum type first?

In VS2008, you could write, for instance, dim enumValue as MyEnum enumValue = .. and then as soon as you typed the =, you'd get a list of possible values of MyEnum. With VS2010, you have to type dim enumValue as MyEnum enumValue = MyEnum. ... before getting the list on typing the final . This makes for a lot more typing and seem...

c++. compile error. am trying to add friend template function with enum template parameter

Hello, dear programmers! Please help with the next code: typedef enum {a1, a2, a3} E; template<E e> int foo() { return static_cast<int>(e); } class A { A() {}; friend int foo<E e>(); }; The compiler says: error C2146: syntax erorr: missing "," before identifier "e" I would be glad if someone could explain my mistake. ...

How can I know items is in the enum?

In this question, I use xor operator between enum with [Flags] attribute as following: [Flags] enum QueryFlag { None = 0x1, ByCustomer = 0x2, ByProduct = 0x4, ByDate = 0x8 } QueryFlag flags = QueryFlag.ByCustomer | QueryFlag.ByProduct; To add an QueryFlag, of course we should use | operator. flags |= QueryFlag.ByDate; To re...

Restricting an NHibernate query using ICriteria according to an enumeration of enums

I have an entity, with a field of type enum, that is persisted as an integer in my database. When retrieving objects from the database using ICriteria, I wish to restrict the results to those with the field being a member of a collection of enum values. Does Restrictions.In work with a collection of enums? The following does not work. ...

WPF enumeration value as ObjectDataProvider's method parameter

Hi ! I want to pass for as a parameter for the GetValues method from MyItemSourceProvider a concrete value of MyEnum. How to write it please? <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type local:MyItemSourceProvider}"> <ObjectDataProvider.MethodParameters> <!-- ENUM value (e.g. MyEnum.Record1) --> ...

Automapper string to enum

Hi All, I've found a couple of posts that describe similar scenarios to mine but nothing that has the same concept or has been resolved so I'm sure I will get complaints about this question but I still want to ask it so some of you more knowledgeable than my self can give me some advice. My problem is hydrating a Viewmodel from a Lin...

Best way to toggle Div Visibility depending on Query String in c# ?

Hi There, I have about 20 div's in an aspx page. At any time, only one of them will be visible. I need to decide which div to show depending on the Query String. http://...?mode=&lt;ModeName&gt; The easy way would be to start with all div's invisible, then just put the QueryString in switch and write out cases for all the possible Mo...

Why would C# allow an invalid enum value

I've spent a while trying to understand why my WPF app wasn't databinding to an enum property propertly and this is the cause. static void Main(string[] args) { MyEnum x = 0; Console.WriteLine(x.ToString()); Console.ReadLine(); } public enum MyEnum { First = 1, Second = 2 } Essentially the problem was that there was n...

Undefined Enum & WPF ComboBox & WCF Serialization

I'm having problems finding a general solution to deal with Enum fields on WPF and WCF, I need a little bit of help. Let's explain with an example: When creating a person with a Sex enum value [Male, Female] I see three posibilites: Male is default -> There are two posibilities but one is default. No problems binding the ComboBox....

Char to Enum in Index View in MVC

I have HelpBoxes in my DB. those are messages people get on the site. each message has a receiver. either it's an organisation or a user, or both. I have this Enum public enum Ontvangers { All = 'A', Organisation = 'I', User = 'D' } now in my index view public ActionResult Index(string schooljaarp...

How to determine the represented type of enum value?

Consider the following two enums: enum MyEnum1 { Value1 = 1, Value2 = 2, Value3 = 3 } enum MyEnum2 { Value1 = 'a', Value2 = 'b', Value3 = 'c' } I can retrieve the physical value represented by these enum values through explicit casting, ((int)MyEnum1.Value2) == 2 or ((char)MyEnum2.Value2) == 'b', but what i...

Extract Data from XML into C# object using LINQ to XML, Enums

I am trying to extract data from XML file and save it my C# class/object. My problem is I have an XMl file like this <personal_auto xmlns = "http://cp.com/rules/client"&gt; <claim id = "s1" type = "Subject Section"> <report > </report> <policy> </policy> </claim> <claim id = "s2" type = "Vehichle Section"> ...

Why aren't TypeLib enums exposed as enums in Visual Basic 6.0?

I have a VB6 project that references COMSVCSLib and one of the methods makes calls to COMSVCSLib's SharedPropertyGroupManager.CreatePropertyGroup passing LockMethod and Process as parameters. Cleaned up VB6 code: Dim groupName As String Dim spmMgr As COMSVCSLib.SharedPropertyGroupManager Dim spmGroup As COMSVCSLib...

Error when implementing Enums using Actionscript 3

Hi All Ours is a Flex/Parsley/Blazeds/Spring project & I'm trying to implement java Enums in Actionscript3 and all I have to do is to send the Enum value to Spring service method. The Java Enum Code (this is generated from XSD) public enum ReferenceLookupType { PATIENT_VISIT_TYPE("PATIENT_VISIT_TYPE"), PATIENT_STATUS( ...

Generic enum parameter in java. Is this possible?

Hi, I am trying to write a generic function that will accept any enum, and put the values into a map for use in a drop down. This is what I have so far, (for a specific enum), can my function enumToMap be rewritten generally to accept any enum type? import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import ...

Default values for enums using the default keyword?

Anyone knows the default value for enums using the default keywords as in: MyEnum myEnum = default(MyEnum); Would it be the first item? ...

Overloading Enums and Properties in VB.NET

Hi I have a base class with the the following enum and property: Public Enum InitType Focus = 0 Help = 1 ErrorToolTip = 2 End Enum Property ToolTipInitType() As InitType Get Return m_initType End Get Set(ByVal value As InitType) m_initType = value ...

Problem in java enum injection using spring

Hi, I'm trying to inject java enum through spring context using Here's what I've done. In my spring config, I've following entry <util:constant id="Content" static-field="com.test.taxonomy.model.MetadataTypeEnum.CONTENT_GROUP" /> Here, I'm trying to leverage an Enum ADSKContentGroup to be injected in my bean's (ADSK...

Enumerated type with arbitrary integer values

I want something like enum EnumType {val1 = -1, val2 = 1}; enum EnumType2 {val1 = 1, val2 = -1}; In particular, val1 and val2 depend on the enumerated type--EnumType or EnumType2. So I eventually want to be able to say something like EnumType x = val1; EnumType2 y = val1; and have x and y have different values. Is the foregoing p...

Java Enums - Number add() and classification method

hi, I am creating an api for a phonebook which has 3 different types of phone-numbers:FAX, HOME, WORK, CELL I want to add a number to a specific type but do not want to classify FAX,HOME,WORK etc. as primitive types as I am considering that I could change it at a later date. I was trying to use enums but am not clear how I can use it ...