함수에서 익명 형식을 반환 형식으로 사용하고 그 반환 값을 배열이나 컬렉션에 넣을 수 있습니까? 또한 새 배열/컬렉션에 추가 필드를 추가 할 수 있습니까? ... 내 의사 변명함수에서 익명 형식을 반환하십시오.
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) –