Reputation: 12005
I initialized an object:
object[,] A = new object[range.RowCount() + 1, range.ColumnCount() + 1];
After filling this I need to iterate all elements of object in loop.
How to iterate this in for loop
?
I tried to do: for(var i = 0; i < A.Count(); i++){}
But there is not property Count()
for object, also this is matrix.
Upvotes: 0
Views: 71
Reputation: 5083
Arrays have Length
property:
for (var i = 0; i < A.Length; i++)
{
var b = A[i, 1];
}
Count()
is a method of IEnumerable
Upvotes: 0
Reputation: 2080
For things like this you might want nested loops, like so:
for (int i = 0; i < A.GetLength(0); i++)
{
for (int j = 0; j < A.GetLength(1); j++)
{
//do your magic
}
}
Upvotes: 3