strange behaviour

Aug 13, 2011 at 6:27 AM

In the following code:

@"

function MyFunction(SomeData) {

switch (SomeData)

{

   case '123':

      return 1;

      break;

   } 

   return 2;

}"; 

 

 

JintEngine engine = new JintEngine ();

engine.Run(script);

 

string data = "123";  

object res = engine.CallFunction("MyFunction", data);

 

 

 

if we pass "123" to the 'data' the script works as expected. But when we pass "12 3"  (non numeric value) then we receive:

 'A first chance exception of type 'System.NullReferenceException' occurred in Jint.dll'.



Is there a way to use Clr strngs in the switch statement?



Thanks,

Khachatur



string script =