```
public class Solution
{
public bool SearchMatrix(int[,] matrix, int target)
{
var row = matrix.GetLength(0);
var col = matrix.GetLength(1);
var curX = row - 1;
var curY = 0;
while(curX >= 0 && curY < col)
{
var matrixValue = matrix[curX, curY];
if (matrixValue == target) return true;
else if (matrixValue < target)
{
curY++;
}
else if (matrixValue > target)
{
curX--;
}
}
return false;
}
}
```