7
Answers

Arrays' initial value - how do you set it?!

Ask a question
Simon

Simon

15y
4.9k
1

Assume an array:

double[,] array = new double[x,y];

I know that the elements will be initialised to zero but I want to set every one of the array to a 'double.NaN'.

I did initially try a foreach loop, but the compiler complained. The only other way is two nested 'for' loops acting with x and y. Is there an easier way?


Answers (7)