Reputation: 3
I'm using a visual basic library and one of the methods I'm using calls for a System.Array to be passed into it. I've tried using "double[]" and "Object[]" when declaring my array however those will not pass. I'm not sure how to convert/declare a "System.Array".
Object[] filledVals = new Object[9];
xyz.getDoubleArray("NumVoids", out filledVals); //where .getDoubleArray(string, System.Array)
Upvotes: 0
Views: 1951
Reputation: 43886
Simply declare it as System.Array
:
Array filledVals;
xyz.getDoubleArray("NumVoids", out filledVals);
Since it is an out
parameter, you don't need to initialize it as it must be initialized by getDoubleArray
.
To convert it to a double[]
you can use this:
double[] result = filledVals.OfType<double>().ToArray();
Upvotes: 3
Reputation: 37045
You can use LINQ:
System.Array result;
xyz.getDoubleArray("NumVoids", out result);
var filledVals = result.OfType<double>().ToArray();
Upvotes: 3