I'm trying to access an array from C# in Javascript.
That's the JavaScript code:
var testArray = window.external.testfunction();
for(var i = 0; i < testArray.length; i++) {
alert(testArray[i]);
}
I tested it with following C# object assigned to the ObjectForScripting property:
[ComVisible(true)]
public class TestObject
{
public string[] testfunction()
{
var test = new string[1];
test[0] = "test";
return test;
}
}
Already when trying to access testArray.length
it throws an JavaScript error saying "function expected".
So how can I return an array back to the JavaScript code?
The JavaScript code is fix (I cannot modify it). So the function will be called with window.external.testfunction()
and as return value the JavaScript code expects an array.
How can I accomplish that from the C# side?
Best regards and thank you for any ideas on that
Andreas