Specified cast is not valid

Feb 24, 2009 at 10:54 PM
Edited Feb 24, 2009 at 10:55 PM

I have a split action that takes an enum value and returns an int. In my stepper I need to convert (or cast) action[0] to the enum. I saw an example in the Client/Server where they cast action[0] to string, which makes sense, but I found no example where conversion from action[0] to enum is done. Could you post a code example how it can be done?

In my model:
Public enum Level {Level1=0, Level2};

[Action] static int SetLevel(Level level){…}

In my stepper I’m trying to do:
   case "SetLevel_Start":
      return CompoundTerm.Create(
      (int)this.SetLevel( (int)action[0]  )); // I get "Specified cast is not valid." How do I cast it to int or enum Level?