我在VB6下面的代码:UBound函数阵列VB6转换到C#
Dim frpdReport() As REPORTDEF
For iCounter = 0 To UBound(frpdReport)
With frpdReport(iCounter)
If .iReportID = iReportID Then
fGetReportFile = .tReportFile
End If
End With
Next iCounter
我转换到这个C#代码:
REPORTDEF[] frpdReport = new REPORTDEF[6];
for (iCounter = 0; iCounter < Convert.ToInt32(frpdReport[6]); iCounter++)
{
if (frpdReport[iCounter].iReportID == iReportID)
{
fGetReportFile_return = frpdReport[iCounter].tReportFile;
}
}
return fGetReportFile_return;
调试时我收到以下错误,for语句- “指数数组的边界之外。”我不明白为什么自阵列的索引是6.
请帮忙吗?
需要注意的是这些代码样本甚至不会启动,并且'Dim'后面的VB6样本中缺少一些内容,因为这会导致单元化数组失败。 – Deanna 2012-07-25 14:00:36