Worksheet Function.CountIfs(...) in C# return value is a 2 dim Object Array
<p>My Problem is that i want to use the <code>WorksheetFunction</code> method <code>CountIf</code> in C# for Excel.</p>

<p>And I'm always getting an 2 dim object array from that function</p>

<pre><code>double[,] zn1 = wsf.CountIfs(cSheet.Range[cSheet.Cells[13, 1],
     cSheet.Cells[20, 1]], sName + sName);
</code></pre>

<p>(It works only with <code>double[,] zn1</code> or <code>var zn1</code>, otherwise I'm getting an error that the object array <code>obj[,]</code> can't be converted to a <code>double</code> or <code>double[]</code>, <code>string[]</code> etc.")</p>

<p>where <code>wsf</code> is defined as</p>

<pre><code>Excel.Application xl = new Excel.Application();
Excel.WorksheetFunction wsf = xl.WorksheetFunction;
</code></pre>

<p>So when I run it, I'm getting a 2 dim object array, which has the same length as the Range, I'm looking for, and all entries contain the same number "-2146826273".</p>

<p>And If I convert the array to a 1 dim double array, the return is <code>System.Double[]</code>.</p>

<pre><code>object[] to = zn1.Cast&lt;object&gt;().ToArray();
object[] res = to as object[];
double[] sRes;
sRes = res.OfType&lt;double&gt;().ToArray();
</code></pre>

<p>All other <code>WorksheetFunction</code> methods  are working well and without errors.</p>

<p>So my question is how, do I get an normal value for the <code>WorksheetFunction</code> method  <code>CountIfs(...)</code>? </p>

<p>And yes I have to use <code>WorksheetFunction</code> methods and I can't enter it like a Formula with a string.</p>