```
public class Solution {
public bool SearchMatrix(int[,] matrix, int target)
{
int target_lvl=0;
int uuper = matrix.GetUpperBound(0);
int llowr = matrix.GetLowerBound(0);
long num = matrix.GetLength(1)-1;
bool gofor = false;
for (int i = 0; i <= uuper; i++)
{
if (target <= matrix[i,num])
{
target_lvl = i;
gofor = true;
break;
}
}
if(gofor)
{
for (int i = 0; i <= num; i++)
{
if (target == matrix[target_lvl,i])
{
return true;
}
}
}
return false;
}
}
```