MattNorman
Well-known member
- Joined
- May 22, 2021
- Messages
- 98
- Programming Experience
- 1-3
I am getting an index out of range exception even though the index I am trying to access is within the bounds of the collection.
If I add a break point I see the size of the collection as 44 and it fail when trying to access the index 33. If I inspect the collection index 33 is present and contains all of the expected data.
I added some logging to see what the index was and the count at the time but this didn't help me to figure out the issue. It just shows the index incrementing and the count always remains at 44 until it hits index 33.
If I add a break point I see the size of the collection as 44 and it fail when trying to access the index 33. If I inspect the collection index 33 is present and contains all of the expected data.
C#:
double startTime = -1;
double endTime = -1;
for (int i = 0; i < data.Count; i++)
{
indexTest = i;
DataManagerLogs.WriteToErrorLog($"{classNamespace}.{methodName}", indexTest.ToString(), data.Count.ToString());
if (i >= data.Count) { continue; }
if (startTime == -1 && int.Parse(data[i].CallsOffered) > 0) { startTime = DataHelper.ReportSecondsFromString(data[i].Time); }
if (int.Parse(data[i].CallsOffered) > 0) { endTime = DataHelper.ReportSecondsFromString(data[i].Time); }
}
I added some logging to see what the index was and the count at the time but this didn't help me to figure out the issue. It just shows the index incrementing and the count always remains at 44 until it hits index 33.