I'm working around an array, in which i wanna add some of its values. At some points, for this do be done with just one calculation, it will ask for an index outside the array.
Is there a way to say, 'if an index is outside the array, assume the value to be 0' ?
Something a bit like this:
try
{
grid[x,y] = grid[x-1,y] + grid[x-1,y-1];
//This is simplified
x++;
}
catch (IndexOutOfRangeException)
{
grid[x - 1, y - 1] = 0;
}