Search code examples
javascriptc#jint

C# Jint Set value to javascript variable


Need to assign value to javascript variabile

in this example in need to return value.

1° First i register a simple function

Engine js = new Engine();
js.SetValue("get_s_width",new Action<int>(get_s_width));


 public void get_s_width(int i)
        {
            js.Execute("function test() { return 100; } test();");                                     
        }

In this case, i try to return a value from C# function but after execute the metod, on the screen i see "null" value how to?

anyone have a idea?


Solution

  • You need to call engine.GetCompletionValue() to retrieve the latest evaluated statement result.