Thanks for the feedback. I will do just as you suggested.As much fun as it would be to write out that code for ourselves, please post it as text, formatted as code, and avoid posting pictures of code in the future. Also, please provide a more complete explanation of the problem. I don't see where you're even trying to access the array elements so how could it be failing?
static void Main(string[] args)
{
var d = new[]
{
new[,]
{
{4, 5}, {7, 9}, {2, 3}
},
new[,]
{
{8, 4}, {6, 7}
}
}
for( i = 0; i < d.Lenght; i++)
{
for(j = 0; j < d[i].Lenght; j++)
{
console.write(j) // I can get the index position of the items in the array.
console.write(d[i][i, j]) // I get IndexOutOfRangeException error
}
}
}
d[i].Length
is not returning what you think it is returning. It is returning the the total number of elements in the array, as per the documentation.(emphasis mine.)Gets the total number of elements in all the dimensions of the Array.