I've been in a similar situation. I solved the problem by implementing a
method that first casts the returned array and then converts the
returned array to a String array.
Using the method o2s (you might find a better name) below you can do
something like:
string[] arrData = o2s(comPlusObje ct.Execute("a", "b", "c"));
// Then just use the String array
Console.WriteLi ne( arrData[0] );
The method has been designed to access Lotus Notes String item values
using the Domino COM interface (domlib.tlb).
The number of String elements returned will be equal to the number of
elements returned by the called COM method.
This could probably also have been done by a simple System.Array.Co pyTo,
but in order to avoid null pointer exceptions I wanted to set the first
String element to an empty string if the COM method returns null.
I'm using the code below in a console application. Depending on your
implementation you may have to remove the static attribute.
static string[] o2s ( Object obj){
// cast the System.Object to a System.Array
Array objArray = (Array) obj;
// create a string array of same size
string[] strArray = new string[objArray.Length];
// loop through the System.Array and populate
// the String Array
for (int i = 0; i < objArray.Length ; i++) {
if (objArray.GetVa lue(i) == null)
// In order to avoid null pointer exceptions
// we will return an empty string in the first
// element if the first element retruned by
// the call to the COM method is null.
strArray[i] = "";
else
strArray[i] = (string)objArra y.GetValue(i).T oString();
}
return strArray;
}
*** Sent via Devdex
http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!