我想将以下查询绑定到DataGridview。 我怎么能这样呢?
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var numberGroups =
from num in numbers
group num by num % 5 into numGroup
select new { Remainder = numGroup.Key, Numbers = numGroup };
答案 0 :(得分:1)
你希望它如何在DGV中表示,因为Numbers可以包含多个项目,这将如何进入DGV行?
或者这应该有效:
var numberGroups = from num in numbers
group num by num % 5 into numGroup
select new { Remainder = numGroup.Key, Count = numGroup.Count() };
yourGridView.DataSource = numberGroups.ToList();
yourGridView.DataBind(); //don't use if WinForm DGV