I have a class called Questions, in this class is an enum called question which looks like this.
public enum Question
{
Role = 2,
ProjectFunding = 3,
TotalEmployee = 4,
NumberOfServers = 5,
TopBusinessConcern = 6,
}
In the Question class I have a get(int foo) function that returns a Question object for that foo...
I'm having trouble with enum visibility in an Objective-C program. I have two header files, and one defines a typedef enum. Another file needs to use the typedef'd type.
In straight C, I would simply #include the other header file, but in Objective-C, it's recommended not to use #import between header files, instead using forward @class...
Why is it that the following code won't work:
endDate.AddDays(7-endDate.DayOfWeek);
While this will:
endDate.AddDays(0-endDate.DayOfWeek + 7);
?
(By "won't work" I mean results in the following compilation error: "cannot convert from 'System.DayOfWeek' to 'double'")
...
Is there a way to share an enum definition between native (unmanaged) C++ and (managed) C#?
I have the following enum used in completely unmanaged code:
enum MyEnum { myVal1, myVal2 };
Our application sometimes uses a managed component. That C# component gets the enum item values as ints via a managed C++ interop dll (from the nativ...
I know there is a way to make enum work for string types with conversions galore - the code doesn't look pretty.
Does anyone know of any way to have something like this:
public SOMESTRUCTURE SessionKeys : string
{
value1 = "value1key",
value2 = "value2key",
name = "name"
}
so later in my code I could refer to it as:
...
I have a switch statement in Java, on an Enum which let us call IMyInterface.MyEnum
Each of my case statements has the form:
IMyInterface.MyEnum.MyValue, (though I could drop the IMyInterface if I imported).
However, the compiler (Java 6) throws an error:
"The qualified case label IMyInterface.MyEnum.MyValue must be replaced with the u...
I'm not sure if I am abusing Enums here. Maybe this is not the best design approach.
I have a enum which declares the possible parameters to method which executes batch files.
public enum BatchFile
{
batch1,
batch2
}
I then have my method:
public void ExecuteBatch(BatchFile batchFile)
{
string batchFileName;
...
...
Is it possible to get the enumeration values from a Class? Let me elaborate this a bit. If I have an enum for example FooBar, then I can get the values of FooBar by calling FooBar.values() which will return an array with the enumerations (FooBar[]). My problem is, that I have a method which takes as an input parameter a class (Class c) a...
Hi!
I have a situation that may seem ridiculus but I have not been able to figure out a good enough solution. To simplify things the problem is something like this, suppose you have an object like Manufacturer that has a countryname property (like car.Manufacturer.CountryName) and you want to be sure that the countryname property can no...
Hi there,
public enum Foos
{
A,
B,
C
}
Is there a way to loop through the possible values of Foo?
Basically?
foreach(Foo in Foos)
...
I have the following statement:
select new Action {
ParentContentType = action.ParentContentType != null ? (ContentType)Enum.ToObject(typeof(ContentType), action.ParentContentType) : null
};
ParentContentType is a nullable enum of type ContentType
action.ParentContentType maps to a database table which is a nullable int.
If ac...
Is there a way i can make my enum defaulted as ints? so i dont need to typecast it everywhere?
Basically i am using it as a list of const values.
...
I am working on a large-scale checkout application for a current project.
This checkout has many cases depending on the user's admin level, how they got to the checkout, and what type of item they are checking out, and so the process is abstracted away from the .aspx pages via a set of context classes.
These classes all subclass from a ...
I have an enum called Permissions. A user can be assigned permissions, or permissions can be asigned to a role and the user can be given a role.
User and Role both have a property like this:
public virtual IList<Permission> Permissions { get; set; }
I want to use an enum for Permissions so in my code I can do things like
public sta...
I want to declare a nested enum like:
\\pseudocode
public enum Animal
{
dog = 0,
cat = 1
}
private enum dog
{
bulldog = 0,
greyhound = 1,
husky = 3
}
private enum cat
{
persian = 0,
siamese = 1,
burmese = 2
}
Animal patient1 = Animal.dog.husky;
Can it be done?
...
I want to do the same as in this question, that is:
enum DaysOfTheWeek {Sunday=0, Monday, Tuesday...};
string[] message_array = new string[number_of_items_at_enum];
...
Console.Write(custom_array[(int)DaysOfTheWeek.Sunday]);
however, I would rather have something integral to so, rather than write this error prone code. Is there a bu...
Hello everyone,
Suppose I have a method and the return type is enum, my question is should I declare the enum as DataContract or not?
Samples like, in the sample, OrderStatus is an enum data type,
OrderStatus Poll(string queryID);
Should I declare OrderStatus enum type as DataContract?
thanks in advance,
George
...
I'm sure this is either totally impossible or really easy:
If I'm creating a table and I want one of the columns to have limited options, it seems that I use either the ENUM or SET value type. But I have to define the possible values at that moment. What if I have another table which has two columns, a primary key column and a data colu...
I have the following code.
private Enum MyEnum
{
VALUE1=5, VALUE2=4, VALUE3=3, VALUE4=2, VALUE5=1
}
protected void Page_Load(object sender, EventArgs e)
{
Session["EnumValue"] = "VALUE1";
MyEnum test = (MyEnum) Session["EnumValue"];
}
In the page load, after the casting i have the value of the variable 'test' = 'VALUE2'.
...
Hello,
I'm compiling C++ code and I'd like to enable the -pedantic option.
I'm using GCC 4.0, running Xcode on Mac OS X Leopard.
It is for example possible to allow variadic macros and the long long type that are normally forbidden when using -pedantic (with -Wno-variadic-macros and -Wno-long-long).
But I could not find anything to disa...