Q:

Initializing two dimensional array of objects

I have a 2-dimensional array of objects, which I initialize using the traditional loop:
PairDS[,] tempPb1 = new PairDS[LoopCounterMaxValue+1, LoopCounterMaxValue+1];
for (int i = 0; i <= LoopCounterMaxValue; i++)
   for (int j = 0; j <= LoopCounterMaxValue; j++)
      tempPb1[i, j] = new PairDS();

Is there any better way to do this using Enumerable or something? 

A:

I thought Initialize could do it, but it only works with value types.
int N = 10;
PairDS[,] temp = new PairDS[N + 1, N + 1];
temp.Initialize();

What I recommend you do is use a jagged array.
class PairDS { public PairDS(int row, int col) { } }

static void Main(string[] args)
{
    int N = 10;
    PairDS[][] temp = Enumerable.Range(0, N + 1).Select(
        (row) => Enumerable.Range(0, N + 1).Select(
            (col) => new PairDS(row, col)).ToArray()).ToArray();
}

