Using C# strings in the switch statement

Aug 12, 2011 at 3:26 PM

Hello,

Is it possible to use C# strings in the switch statement?

I got 'A first chance exception of type 'System.NullReferenceException' occurred in Jint.dll'  exception while trying to do it.

Here is a simple code to reproduce is:

   JintEngine jintEngine = new JintEngine();   

   string script = "function MyFunction(SomeData) { switch (SomeData) { case '123': break; } }";

   jintEngine.Run(script);

   string data = "123";

   jintEngine.CallFunction("MyFunction", data);

 

Thanks,

Khachatur

 

Developer
Aug 12, 2011 at 9:25 PM

please specify what version of Jint are you using?

thanks.

Aug 12, 2011 at 10:04 PM

Hello,

I am using the binary version downloaded from codeplex. The assembly version (Jint.dll)  is 0.9.0.0

Just tried to use

JsString data = new JsString("123");

instead of

string data = "123";

jintEngine.CallFunction("MyFunction", data);

but with no luck. 

 

Thanks,

Khachatur