DEV Community

Discussion on: how to fix Index was outside the bounds of the array error?

Collapse
 
peledzohar profile image
Zohar Peled

Never attempt to catch an IndexOutOfRangeException when using arrays. This exception can be avoided simply by making sure your index is within the range - which in arrays means larger than -1 and smaller than array.Length.

For more information, read Eric Lippert's blog post entitled Vexing Exceptions