我可以在函数中使用匿名类型作为返回类型,然后将值返回给某个数组或集合中的某种东西,同时还将新的字段添加到新的数组/集合中?原谅我...伪返回匿名类型从函数
private var GetRowGroups(string columnName)
{
var groupQuery = from table in _dataSetDataTable.AsEnumerable()
group table by new { column1 = table[columnName] }
into groupedTable
select new
{
groupName = groupedTable.Key.column1,
rowSpan = groupedTable.Count()
};
return groupQuery;
}
private void CreateListofRowGroups()
{
var RowGroupList = new List<????>();
RowGroupList.Add(GetRowGroups("col1"));
RowGroupList.Add(GetRowGroups("col2"));
RowGroupList.Add(GetRowGroups("col3"));
}
的可能重复的[访问C#匿名类型对象(http://stackoverflow.com/questions/713521/accessing-c-sharp -anonymous-type-objects) – nawfal
[Return anonymous type?]可能重复(http://stackoverflow.com/questions/534690/return-anonymous-type) –