+ 2
Another way to display a Multidimensional Array using the indexes and understand how the rows and columns are indexed:
int[ , ] sn = {{2,3},{5,6},{4,6}}; Console.WriteLine("{0}{1}", sn[0,0],sn[0,1]); Console.WriteLine("{0}{1}", sn[1,0],sn[1,1]); Console.WriteLine("{0}{1}", sn[2,0],sn[2,1]);
1 Answer
+ 1
int[ , ] sn = {{2,3},{5,6},{4,6}};
for (int s = 0; s < sn.Length / sn.Rank; s++)
{
for (int n = 0; n < sn.Rank; n++)
{
Console.Write(sn[s,n]);
}
Console.WriteLine();
}
}