I would avoid using StringBuilder
in your examples. The String.Join
method is very useful for expanding a collection of strings. You can try something along these lines.
public static void Main()
{
object[][] data =
[
["Id", 1,"Name", "Alice","Age", 30,"City", "New York","Occupation", "Engineer",
"Hobby", "Reading"],
["Id", 2, "Name", "Bob", "Age", 28],
["Id", 3, "Name", "Charlie", "Age", 35]
];
List<string> list = [];
foreach (object[] row in data)
{
var result = string.Join(' ', row);
list.Add(result);
}
Console.WriteLine(string.Join("\r\n", list));
Console.ReadLine();
}