The method Array.Clear takes the following parameters:
- Array array - the Array on which the Clear will be performed.
- int index - the starting position from which to start clearing
- int length - the number of elements which should be cleared.
A bit of test coding covereth a multitude of sins... including sins of misleading or unhelpful documentation.
In your case, the index caused the exception: the last valid position would be Length - 1.
As to the solution: if you intend to clear the entire array while retaining bot initial pointer and array size, the answer is:
Array.Clear(boardposition, 0, boardposition.Length );
If, however, you have no issues with changing the address of the Array, just assign it a new Array with same length; the end result would still be a zeroed Array of length 9:
boardposition = new char[9];
Edit: the best use scenario depends entirely on how boardposition is used later on in the program.