我在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