using System;
using System.Text;
public class ConvertSpecificRowOfMatrixToString_CSharp
{
public static string ConvertRowOfMatrixToString(int[,] matrix, int row) {
int cols = matrix.GetLength(1);
StringBuilder sb = new StringBuilder();
for (int j = 0; j < cols; j++) {
sb.Append(matrix[row, j]);
sb.Append(" ");
}
return sb.ToString().Trim();
}
public static void Main(string[] args)
{
int[,] matrix = {
{4, 7, 9, 18, 29, 0},
{1, 9, 18, 99, 4, 3},
{9, 17, 89, 2, 7, 5},
{19, 49, 6, 1, 9, 8},
{29, 4, 7, 9, 18, 6}
};
int row = 2;
string str = ConvertRowOfMatrixToString(matrix, row);
Console.WriteLine(str);
}
}
/*
run:
9 17 89 2 7 5
*/