I have the following code in VB6:
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
And I converted to this C# code:
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;
When debugging I get the following error in the for Statement – “Index was outside the bounds of the array.” And I cannot figure out why since the index of the array is 6.
Any help please?
Why not use the .length property?
or if you don’t need the counter value, a for each
Or if you are looking for a specific item, use LINQ