Call JavaScript method with C# object as parameter #1433
Answered
by
achimmihca
achimmihca
asked this question in
Q&A
-
The documentation shows how to create a C# object instance from JS:
My question is, how can I pass an instance of
|
Beta Was this translation helpful? Give feedback.
Answered by
achimmihca
Feb 14, 2023
Replies: 2 comments 3 replies
-
Might be easier like this after registering the type to engine. const result = engine.Execute("const jsObject = new MyJsClass();").Evalute("jsObject.doSomething(new TheType());"); Or engine.SetValue("myType", new TheType());
const result = engine.Execute("const jsObject = new MyJsClass();").Evalute("jsObject.doSomething(myType));"); |
Beta Was this translation helpful? Give feedback.
1 reply
-
JsValue.FromObject can be used to convert C# objects to its JS counterpart. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
achimmihca
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JsValue.FromObject can be used to convert C# objects to its JS counterpart.