Issue
I have the following enum:
enum EditMode {
View = 0,
Edit = 1,
Delete = 2
}
Let's assume I have a variable of the enum type
var editMode = EditMode.Edit;
Why does the following code not work (goes straight to default)?
switch (editMode) {
case EditMode.Delete:
// ...
break;
case EditMode.Edit:
// ...
break;
default:
// ...
break;
}
Solution
I have found why this happens: somewhere in the code there is a activation function (I am using durandal) which passes this enum as a string (the function has the parameter marked as a enum but still it is a string). This is why my switch statement fails.
I simply converted the value to a number and now everything works as expected.
Answered By - Mantzas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.