ron <goodr@no_spam_for_me_mddm.panasonic.com> wrote:
Could i clear the a single dimension array and a jagged
array in the following way.
int[] mySingleArr = new int[10];
mySingleArr = System.Array.Clear();
No, because Array.Clear takes arguments and returns void. You mean:
Array.Clear (mySingleArr, 0, mySingleArr.Length);
int[][] myJaggedArr = new int[3][];
myJaggedArr = new int[0][3];
myJaggedArr = new int[1][3];
myJaggedArr = new int[2][3];
myJaggedArr = System.Array.Clear();
Is this possiable without iterating through the arrays
and setting the elements to zero?
In this case you're not actually wanting to clear myJaggedArr itself,
which would set it back to being an array of 3 null references, but
each member of those three arrays - so you need to do precisely that:
foreach (int[] subArray in myJaggedArr)
{
Array.Clear (subArray, 0, subArray.Length);
}
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too