Omgili - forum search, search forums  
  

Discussions about use an enum

Displaying 1 - 10 out of 10,415 discussions.  
RSS Feed Options
Time Frame: (Any time)   Minimum number of replies: (2)   Minimum number of discussing users: (0)
  |  

Page: 1   2   3   4   5   6   7   8   9   10  
Keep this page open to be updated with the newest discussions automatically.
I imagine everyone has seen code like: public void Server2ClientEnumConvert( ServerEnum server) { switch(server) { case ServerEnum.One: return ClientEnum.ABC //And so on. Instead of this badness we could do somthing like: public enum ServerEnum { [Enum...
Started by on , 6 posts by 6 people.  
I would probably use struct as the type, and then throw an exception if it isn't an Enum type Jennings I read through the rules there and found: "An enum type, provided it has public accessibility does trying for Enum e in ....
I'm trying to lookup against an Enum set, knowing that there will often be a non-match which throws an exception: I would like to check the value exists before performing the lookup to avoid the exceptions. My enum looks something like this: public enum...
Started by on , 7 posts by 7 people.  
You could build a....
But I understand you don't want it.
It will probably have the best performance of all.
Public enum Fruit { APPLE("apple"), ORANGE have only a few enum values.
When I do this I usually graft it onto my enum class.
Scala doesn't have type-safe enum s like Java has. If I have a set of related constants then what is the best way in Scala to represent those constants?
Started by on , 6 posts by 6 people.  
In order to get something most closely....
Http://www.scala-lang.org/docu/files/api/scala/Enumeration.html Example use object Main extends documentation by skaffman above is of limited utility in practice (you might as well use case object s).
Ask your Facebook Friends
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
Started by on , 12 posts by 12 people.  
Here's my suggestion : Use an enum type pattern.Although you null; } You can use it like....
/// Prerequisite : All enum members should be applied them to have some friendly name .
Type" then you should use this method.
Just a quick question regarding enums. Say I have an enum which is just public enum Blah { A, B , C, D } and i would like to find the enum value of a string of for example "A" which would be Blah.A - How would it be possible to do this? Is the Enum.ValueOf...
Started by on , 5 posts by 5 people.  
Here's a nifty utility I use: /** * A common method for all enums since they can't have another....
A".toUpperCase()) would work :p Using Blah.valueOf(string) is best but you can use Enum.valueOf(Blah.class, string) as well.
What is the correct way of casting (in C++/CLI) from a native code enum to a managed code enum which contain the same enum values? Is there any difference with using the C# way of casting like for example (int) in C++/CLI.
Started by on , 3 posts by 3 people.  
If your native C++ code use unsigned....
By default the CLI enum is based on int, which should be fine in most cases.
For example, if you have a CLI enum that has an underlying type of ushort, it cannot hold a vallue of 257.
It depends.
Hello. I was just wondering why people use enums in C++ as constants while they can use const . Thanks
Started by on , 13 posts by 13 people.  
An enumeration must have all its values: enum....
Template <int N> to as the “enum hack”) was to use an untagged enum with no instances.
use values from an enum, but not a static const int to instantiate a class.
I've got the class object for an enum (I have a Class<? extends Enum> ) and I need to get a list of the enumerated values represented by this enum. The values static function has what I need, but I'm not sure how to get access to it from the class...
Started by on , 4 posts by 4 people.  
Class.getEnumConstants using reflection is simple as calling Class#getEnumConstants() : List<Enum> enum2list(Class<? extends Enum> cls) { return Arrays.asList(cls.getEnumConstants()); } If you know the name of the value you need: ....
Hi, Is there a way to persist an enum to the DB using NHibernate? That is have a table of both the code and the name of each value in the enum. I want to keep the enum without an entity, but still have a foreign key (the int representation of the enum...
Started by on , 6 posts by 6 people.  
One of the ways I would probably try out is Oran Dennison's Generic NHibernate Enum String Mapping....
Value; } } You can use the enum type directly: http://graysmatter.codivation.com/post/Justice results on NHibernate Enum .
Hi All I came across thas problem that I without knowing the actual enum type i need to iterate its possible values. if (value instanceOf Enum){ Enum enumValue = (Enum)value; } Any ideas how to extract from enumValue its possible values ? Thanks
Started by on , 4 posts by 4 people.  
Your current code....
You can do it like soObject[] possibleValues = enumValue.getDeclaringClass().getEnumConstants(); Enum s are just lyke Class es in that they are typed.
To use reflection to find out what the list of enum values is.
Page: 1   2   3   4   5   6   7   8   9   10  
More Information


Forum Search About Omgili Help Plugins Forum/Board Owners Privacy

i
In Title
In Topic
In Reply
Exclude
Boost