In my persistence layer, I've declared a load of Enums to represent tables containing reference data (i.e. data never changes).
In Linq2SQL, I am able to set the type of an entity property to an enum type and all is well, but as soon as I set a second entity's property to use the same enum type, the Code Generator (MSLinqToSQLGenerator)...
I've got an Enum marked with the [Flags] attribute as follows:
[Flags]
public enum Tag : int
{
None = 0,
PrimaryNav = 1,
HideChildPages = 2,
HomePage = 4,
FooterLink = 8
}
On sitemapnodes in my sitemap I store the int value for the tags combination as an attribute.
What I need to do is check if a node has any on...
Hi!
I don’t know if it’s possible, but I want to be able to refer to enums from my WCF service on the client side. I have one core project, and in that project the enums are:
public enum StatusType
{
Ok = 1,
Error = 2,
Unknown = 0
}
public enum DirectionType
{
None = 0,
ToSystem = 1,
FromSystem = 2
}
I...
We have a REST API where clients can supply parameters representing values defined on the server in Java Enums.
So we can provide a descriptive error, we add this lookup method to each Enum. Seems like we're just copying code (bad). Is there a better practice?
public enum MyEnum {
A, B, C, D;
public static MyEnum lookup(St...
Hi, I am refactoring a part of our legacy app which handles exporting and importing of DB tables from/to Excel sheets. We have a Formatter subclass for each table, to provide the definition of that table: how many columns it has, and what is the name, format and validator of each column. The getters which supply this data are then called...
I have an enumeration for my Things like so:
public enum Things
{
OneThing,
AnotherThing
}
I would like to write an extension method for this enumeration (similar to Prise's answer here) but while that method works on an instance of the enumeration, ala
Things thing; var list = thing.ToSelectList();
I would like it to work on...
Suppose you have the following class:
class Test : ISerializable {
public static Test Instance1 = new Test {
Value1 = "Hello"
,Value2 = 86
};
public static Test Instance2 = new Test {
Value1 = "World"
,Value2 = 26
};
public String Value1 { get; private set; }
public int Value2 { get; private set; }
publi...
I'm looking for an elegant way to use values in a Java enum to represent operations or functions. My guess is, since this is Java, there just isn't going to be a nice way to do it, but here goes anyway. My enum looks something like this:
public enum Operator {
LT,
LTEQ,
EQEQ,
GT,
GTEQ,
NEQ;
...
}
where LT ...
Is there a way to get all possible values from a MySQL enum column?
The MySQL documentation says the MySQL enum type is returned as a Java String, so I basically would like a way to get all possible strings I can pass when querying a table with such an enum.
I couldn't immediately find anything when I was looking through the metadata r...
Dear ladies and sirs.
I have two entities types:
RunContainer parent entity type
Run child entity type
Run has a property Status, which is of type RunStatus, like so:
public enum RunStatus
{
Created,
Starting,
// ...
}
public class Run
{
public int ContainerId { get; private set; }
// ...
public RunStatus Status { get...
I've switched from using constants for Strings to using enums. Many times I need the String representation of the enum (for logging, to pass to an API that requires a String, etc).
With String constants, you can just pass the String value, but with enums you have to call toString(). Is there a way you can "default" to the String val...
I have a class that contains an enum property, and upon serializing the object using JavaScriptSerializer, my json result contains the integer value of the enumeration rather than its string "name". Is there a way to get the enum as a string in my json without having to create a custom JavaScriptConverter? Perhaps there's an attribute ...
I have a Enum defined as Type
public Enum **Type**
{
OneType,
TwoType,
ThreeType
};
Now I bind Type to a drop down Ribbon Control Drop Down Menu in a Ribbon Control that displays each menu with a MenuName with corresponding Image.
( I am using Syncfusion Ribbon Control ).
I want that each enum type like ( OneType ) has dat...
i'm using enums to replace String constants in my java app (jre 1.5).
is there a performance hit when i treat the enum as a static array of names, in a method that is called constatnly (e.g. when rendering the UI)?
my code looks a bit like this:
public String getValue(int col) {
return ColumnValues.values()[col].toString();
}
than...
Hi,
I have an enum, which looks like
public enum Animal {
ELEPHANT,
GIRAFFE,
TURTLE,
SNAKE,
FROG
}
and I want to do something like
Animal frog = Animal.FROG;
Animal snake = Animal.SNAKE;
boolean isFrogAmphibian = frog.isAmphibian(); //true
boolean isSnakeAmphibian = snake.isAmphibian(); //false
boolean isFrogReptile = fr...
Hi all,
Just out of curiosity, asking this
Like the expression one below
a = (condition) ? x : y; // two outputs
why can't we have an operator for enums?
say,
myValue = f ??? fnApple() : fnMango() : fnOrange(); // no. of outputs specified in the enum definition
instead of switch statements (even though refactoring is possible)...
I have an Enum for Days of week (with Everyday, weekend and weekdays) as follows where each entry has an int value.
public enum DaysOfWeek {
Everyday(127),
Weekend(65),
Weekdays(62),
Monday(2),
Tuesday(4),
Wednesday(8),
Thursday(16),
Friday(32),
Saturday(64),
Sunday(1);
private int bitValue;
private DaysOf...
I currently have a class file with the following enumeration:
using System;
namespace Helper
{
public enum ProcessType
{
Word = 0,
Adobe = 1,
}
}
Or should I include the enumeration in the class where it's being used?
I noticed Microsoft creates a new class file for DockStyle:
using System;
using System....
I looked under the hood for EnumSet.allOf and it looks very efficient, especially for enums with less than 64 values.
Basically all sets share the single array of all possible enum values and the only other piece of information is a bitmask which in case of allOf is set in one swoop.
On the other hand Enum.values() seems to be a bit of...
I've been trying for 3 hours and I just can't understand what is happening here.
I have an enum 'Maze'. For some reason, when the method 'search' is called on this enum it's EXTREMELY slow (3 minutes to run). However, if I copy the same method to another class as a static method, and I call it from the enum 'Maze' it runs in one second!...