If you create your Matrix
int[,] matrix =
{
{ 0, 0, 1, 0, 0},
{ 0, 0, 0, 0, 0},
{ 1, 0, 0, 0, 1},
{ 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0}
};
you will see by using a debugger
that the coordinates of the '1 locations' are not what you expect.
The coordinates are
[0,2]
[2,0]
[2,4]
[4,2]
In order to get these positions you could loop through the matrix and store the items in a list.
public class Item
{
public int X { get; set; }
public int Y { get; set; }
public int Value { get; set; }
}
var items = new List();
for (var x = 0; x < 5; x++)
{
for (var y = 0; y < 5; y++)
{
items.Add(new Item
{
X = x,
Y = y,
Value = matrix[x, y]
});
}
}
The searched positions can be retrieved like this:
var results = items.Where(x => x.Value == 1);