vb的next与c#的for循环同时调用excel函数性能差别这么大?
For i = 1 To LenA
For j = 1 To LenB
TempA = LenA(i)
TempB = LenB(j)
BetaMatrix1(i, j) = (excel.Application.WorksheetFunction.GammaLn(TempA + TempB))
Next j
Next i
-------------------------------以上是VB代码
for (int i = 0; i < LenA.Length; i++)
{
for (int j = 0; j < TempB.Length; j++)
{
TempA2 = LenA[i] ;
TempB2 = TempB[j];
BetaMatrix1[i, j] =(excel.WorksheetFunction.GammaLn(TempA + TempB));
}
}
-------------------------------以上是C#代码
为什么VB的代码速度很快,i+1是秒级算过,运行而c#的代码增加一个i+1需要几十秒,而且测试发现调用excel的函数速度也很快?问题在哪