是否可以将多行连接到单行?
例如:
IEnumerable<sample> sam = new List<sample>()
{
new sample{ id = 1, name = "sample 1", list = new List<int>{1,5,6}},
new sample{ id = 2, name = "sample 2", list = new List<int>{2,9}},
new sample{ id = 3, name = "sample 3", list = new List<int>{8,3,7}},
new sample{ id = 4, name = "sample 4", list = new List<int>{3,4,8}},
new sample{ id = 5, name = "sample 5", list = new List<int>{1,5,7}},
new sample{ id = 6, name = "sample 6", list = new List<int>{6,9,7}}
};
输出必须:
{
new sample { id = 1, name = "sample 1", list = "1,5,6" },
new sample { id = 2, name = "sample 2", list = "2,9" },
new sample { id = 3, name = "sample 3", list = "8,3,7" },
new sample { id = 4, name = "sample 4", list = "3,4,8" },
new sample { id = 5, name = "sample 5", list = "1,5,7" },
new sample { id = 6, name = "sample 6", list = "6,9,7" }
};
这意味着从列表中新行现在是一个字符串。