Modifying a 2-dimensional array

Question | May 18, 2016 | hlone 

A 2-dimensional C# array is declared and initialized as:

int[,] arr2d = { { 2, 3, 10 }, 
                 { 5, 2, 4 } };

The 'arr2d' above has 2 dimensions. It can be visualized as a table having 2 rows and 3 columns, where row is the first dimension and column is the second:

enter image description here

Following code has a lambda expression that captures the above 2-dimensional array and modifies its contents. If you do not know about lambda expressions then you can quickly read about them here. The Array.GetLength(dimension) method returns the length of a dimension.

int[,] arr2d = { { 2, 3, 10 }, 
                 { 5, 2, 4 } };

Action<int,int> RowMult = (m,r) => {
  for(int n=0; n < arr2d.GetLength(r); ++n)
     arr2d[n,0] *= m;           
};

RowMult(2,0);

What will be the contents of 'arr2d' after above call to 'RowMult'?

2015 nextptr