I am running a Console C#.net program in Debug mode in Visual Studio 2022 (Community Edition). It has the following loop:
for (int i = 0; i < result.Length - 1; ++i)
{
result[i] = row[i - 1] + row[i];
}
Of course, there is an out of bound exception at the first iteration. I have set the exception settings like this:
Nonetheless, when the exception happens, the following is the output in the Console and the debug mode is not entered:
6
Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
at ConsoleApp2.Program.next_row(Int32[] row) in C:\Users\mgold\source\repos\ConsoleApp2\Program.cs:line 11
at ConsoleApp2.Program.Main(String[] args) in C:\Users\mgold\source\repos\ConsoleApp2\Program.cs:line 29
C:\Users\mgold\source\repos\ConsoleApp2\bin\Debug\net6.0\ConsoleApp2.exe (process 15220) exited with code -532462766.
Press any key to close this window . . .
Interestingly, this does not happen for all the runs, but I cannot figure out what it depends on. What could be the problem?