Welcome tag moderator AKA Unofficial DEV cheerleader. While most of my friends are found on SnapChat or Tic-Toc, you can find me here. And I OOP, but I’m not a VSCO girl.
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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If you are intentionally accessing something outside the array, put the code in a try/catch block:
Nope, it is not intentionally the purpose here is only to check the element neighbors only
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