1个回答
展开全部
开Linq 用group by into ,再select new个匿名,中间用lamb ToArray()一下,Join
var list1 = new[] {
new { A="a1", B= "0" },
new { A="a2", B= "0" },
new { A="a1", B= "1" },
new { A="a3", B= "1" },
};
var k = from x in list1
group x by x.A into g
select new
{
A = g.Key,
B = String.Join(",", g.Select(c=>c.B).ToArray())
};
dataGridView1.DataSource = k.ToList();
var list1 = new[] {
new { A="a1", B= "0" },
new { A="a2", B= "0" },
new { A="a1", B= "1" },
new { A="a3", B= "1" },
};
var k = from x in list1
group x by x.A into g
select new
{
A = g.Key,
B = String.Join(",", g.Select(c=>c.B).ToArray())
};
dataGridView1.DataSource = k.ToList();
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询