How do I iterate an IGrouping Interface?

前端 未结 5 721
逝去的感伤
逝去的感伤 2020-12-24 00:34

Ive got ths really annoying issue I have grouped a set of data and I cant get to the data within the group. I can get to the key bit not the data..

I have a load of

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-24 01:09

    You can use following code as well.

    var groupedData = Data.GroupBy(x => x.Period);
    
    foreach (var group in groupedData) {
        var gr = group.FirstOrDefault();
        Console.WriteLine("Period: {0}", gr.Period);
        Console.WriteLine("Adjustment: {0}", gr.Adjustment);
    }
    

提交回复
热议问题