P
PokerMan
Hi guys,
Maybe someone can explain thisi have this enum:
public enum LimitType : int
{
BottomLimit,
TopLimit,
Limit
}
In another class i read values from my db and cast them to the enum, where
my db id is 1, it will match the enum that is first and so on:
pt = (myClass.LimitType )int.Parse(limitType);
Here is the weird bit, if limitType is a 1, pt becomes BottomLimit. Correct.
if it is a 2 it becomes TopLimit. Correct.
if it is a 3, it becomes the integer 3. Wrong!?
I thought maybe limit is some kind of keyword to the compiler, so i changed
the enum to this:
public enum LimitType : int
{
BottomLimit,
TopLimit,
Limit,
test
}
Ran it again and in debug this happened:
if limitType is a 1, pt becomes BottomLimit. Correct.
if it is a 2 it becomes TopLimit. Correct.
if it is a 3, it becomes test !? Wrong.
Can anyone explain why it seems to be choosing to skip Limit as though it
isn't there? In debug when i check the enum at runtime it does have Limit as
one of the enums and it is in that order. Look forward to the replies.
Maybe someone can explain thisi have this enum:
public enum LimitType : int
{
BottomLimit,
TopLimit,
Limit
}
In another class i read values from my db and cast them to the enum, where
my db id is 1, it will match the enum that is first and so on:
pt = (myClass.LimitType )int.Parse(limitType);
Here is the weird bit, if limitType is a 1, pt becomes BottomLimit. Correct.
if it is a 2 it becomes TopLimit. Correct.
if it is a 3, it becomes the integer 3. Wrong!?
I thought maybe limit is some kind of keyword to the compiler, so i changed
the enum to this:
public enum LimitType : int
{
BottomLimit,
TopLimit,
Limit,
test
}
Ran it again and in debug this happened:
if limitType is a 1, pt becomes BottomLimit. Correct.
if it is a 2 it becomes TopLimit. Correct.
if it is a 3, it becomes test !? Wrong.
Can anyone explain why it seems to be choosing to skip Limit as though it
isn't there? In debug when i check the enum at runtime it does have Limit as
one of the enums and it is in that order. Look forward to the replies.