D
DKode
I started using Enums to make my code more readable. Here is my ENUM:
public enum EntryType : int {
RegularHours = 1,
Lunch = 2,
Vacation = 3,
Sick = 4,
Personal = 5
}
When I am testing against this enum in code I do the following:
if((int)dr["TypeID"] == (int)EntryType.RegularHours) {
// do something
}
Is it always required for me to cast the Enum to int, even though I
already have that set in the enum declaration? otherwise I get a
compile error about not being able to use the '==' operator against int
and EntryType enum
thanks
Sean
public enum EntryType : int {
RegularHours = 1,
Lunch = 2,
Vacation = 3,
Sick = 4,
Personal = 5
}
When I am testing against this enum in code I do the following:
if((int)dr["TypeID"] == (int)EntryType.RegularHours) {
// do something
}
Is it always required for me to cast the Enum to int, even though I
already have that set in the enum declaration? otherwise I get a
compile error about not being able to use the '==' operator against int
and EntryType enum
thanks
Sean