Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Visual Studio C# view which index throws System.IndexOutOfRangeException

So I have code that loops through a 2D array and assigns it a value from a 1D array in my C# program in Visual Studio. When I execute it I get an "index was outside the bounds of array" error but I have no idea which of the two arrays, or index to the arrays is throwing the error. Because I have a 2D array and a 1D array I have a total of 3 indices I am looping through in a nested loop that could be causing the error. Is it possible in visual studio to see exactly which index I am accessing incorrectly and is throwing the error?

Right now I just have the error message on this line

 2DArray[i,j] = 1DArray[k];

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The quickest two ways would be to use debug stop or to add a watch to each integer "i,j, and k" and when the error breaks/pauses the execution you can also hover over any variable in your code to see values of it as well.

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading