I have a list that simulates an array (or a two-dimensional array) that is structured as follows:
List<List<int>> matriz = new List<List<int>>();
Since this matriz
is initialized with the following values:
matriz.Add(new List<int> {3, 4, 1} );
matriz.Add(new List<int> {2, 4, 5} );
matriz.Add(new List<int> {44, 8, 9} );
And my problem is finding the position of the line and column given a given value. For example, the 44
value is in the 2
line and the 0
column, see:
matriz[2][0] // 44
I tried to use the FindIndex
method this way:
matriz.FindIndex(x => x.Contains(44))
However, it only returns a single value that is the position corresponding to the line that is 2
, and I would need the position of the line and column 2
and 0
.
Question
- How could I get the indices corresponding to row and column
given a given value from a list
List<List<int>>
?