I have the following code that fails with an exception:
It looks like Me.SetValue() expects a value of short type. So, my
question is: How do I call a method in script with parameter with type of short? Is there a way to let the script engine to convert a constant like "123" automatically to short?
short myValue;
public void SetValue(short v) {
myValue = v;
}
void ClearScriptTest2(object sender, EventArgs e) {
using (var engine = new V8ScriptEngine()) {
engine.AddHostObject("Me", this);
engine.Execute("Me.SetValue(123);");
MessageBox.Show(myValue.ToString());
}
}
When I change the type of the parameter, v, for SetValue() from short to int, the code works.It looks like Me.SetValue() expects a value of short type. So, my
question is: How do I call a method in script with parameter with type of short? Is there a way to let the script engine to convert a constant like "123" automatically to short?