Ask a Question

Get variables out of "var" object in C# connected application

Ivg
Occasional Contributor

Get variables out of "var" object in C# connected application

Hi,
 
I'm writing connected application in C#.
 
I want to test Java application.
 
I'm trying to get some string from some object and I can't figure out how to do it.
 
I'm trying something like this:
 
            var comboBox = findComponent(rootComponent, propNames, propValues);
            object aa = comboBox["toString"]();
 
In debugging I can see aa is a "var" type, and it encapsulates a COM object.
When I use the unWarp method, I get the COM object itself. I don't know how to get to the actual String.
Casting it or assigning to a String variable throws a ClassCastException.
 
But for exampe, this line works.
             int itemCount = comboBox["getItemCount"]();
 
"comboBox["getItemCount"]()" returns var object that contains int, not COM object like in the previous example.
Why it is ok with integers but not ok with strings?
It can identify and convert Java int to C# int, but not Java string to C# string?
 
How can I get the string out?
 
Thanks!
0 REPLIES 0
cancel
Showing results for 
Search instead for 
Did you mean: