- Home /
Question by
alphamalet · Jul 22, 2018 at 07:26 PM ·
indexoutofrangeexceptioncatch
Can't Catch IndexOutOfRangeException
I'm having a problem with my C# script, and can't figure out whatI'm doing wrong. Essentially, I am trying to catch a index out of range exception. The problem is, due to my try/catch block, my script will not compile. I am getting this error:
The type or namespace name `IndexOutOfRangeException' could not be found. Are you missing a using directive or an assembly reference?
I must be making a silly mistake somewhere, but I'm not seeing it. Any help would be appreciated.
for(i = (row -1); i <= (row + 1); i++){
for(j = (column - 1); j <= (column + 1); j++){
try{
if(playDeck[i,j].suit == playDeck[row,column].suit){
myNewString = playDeck[i,j].ToString();
Debug.Log (myNewString);
playDeck[i,j].claimed = true;
}
}
catch(IndexOutOfRangeException ex){
Debug.Log ("exception happened");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
UnityException not being caught 1 Answer
How can I check what levels are included in the build in code? 1 Answer
Try/ Catch does not work with Network.InitializeServer 2 Answers
Try and catch very slow 1 Answer
Try Catch not executing. 3 Answers