我可以在函數中使用匿名類型作爲返回類型,然後將值返回給某個數組或集合中的某種東西,同時還將新的字段添加到新的數組/集合中?原諒我...僞返回匿名類型從函數
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) –