+ 2
how to find the index of an element in an array of arrays
how to find the index of an element in an array of arrays, for example: char [] [] array = {{'a', 'b', 'c'}, {'d', 'f', 'g'}}
4 Answers
+ 3
Use 2 nested loops (inner loop in outer loop,). Use one outer loop for traversing a row and other outer loop for traversing column
For I to n
{
For J to m
Array[I][J] , // I represents row while J represents columns..
}
//For n*m array data
+ 1
using System;
namespace Sololearn
{
class Program
{
static void Main(string[] args)
{
char[,]array ={{'a','b','c'},{'d','f','g'}};
for(int i=0; i<2;i++) {
for(int j=0; j<3;j++)
Console.Write(array[i,j]+" ");
Console.Write("\n") ;
}
}
}
}
//edit: corrected now to full code. cs syntax is different, just I noticed. Роман Жигунов..
0
Jayakrishna, please show an example
0
Thank you