C
C#2y ago
A Name

❔ Index Out of Bounds Exception

cs
for (int LinesLeft = LinesOfContent.Length-1; LinesLeft >=0; LinesLeft--)
{
SearchStringForInts(LinesOfContent[LinesLeft]);

}
cs
for (int LinesLeft = LinesOfContent.Length-1; LinesLeft >=0; LinesLeft--)
{
SearchStringForInts(LinesOfContent[LinesLeft]);

}
seems to throw an error on this line if needed I can disclose the function, although the log seemed to think it was on this line
6 Replies
Angius
Angius2y ago
Use the debugger and see what values LinesLeft has at any given time If it throws an exception at the start, it means the collection has no elements Also, you can use
for (var lines = 1; lines < LinesOfContent.Length; lines++)
{
SearchStringForInts(LinesOfContent[^lines]);
}
for (var lines = 1; lines < LinesOfContent.Length; lines++)
{
SearchStringForInts(LinesOfContent[^lines]);
}
to make it a little easier to follow Backwards iteration often takes some trial and error lol
A Name
A NameOP2y ago
switched to your mode gonna check debugger sorry for second question but how do you actual use debugger?
Angius
Angius2y ago
$debug
MODiX
MODiX2y ago
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
A Name
A NameOP2y ago
thanks
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server