如何循环 Dictionary<IEnumerable<string>

班级:


class myClass

{

    public int processId { get; set; }

    public string measurement { get; set; }

    public decimal measurementValue { get; set; }

    public string otherText { get; set; }

}

代码:


List<myClass> myClasses = new List<myClass> {

    new myClass { processId=1, measurement="height", measurementValue=10,otherText="312312" },

    new myClass { processId=1, measurement="length", measurementValue=11 ,otherText="312312"},

    new myClass { processId=1, measurement="width", measurementValue=12 ,otherText="312312"},

    new myClass { processId=2, measurement="height", measurementValue=20 ,otherText="312312"},

    new myClass { processId=2, measurement="length", measurementValue=21 ,otherText="312312"},

    new myClass { processId=2, measurement="width", measurementValue=22 ,otherText="312312"}

};


var groups = myClasses

    .GroupBy(o => o.processId)

    .ToDictionary(g => g.Select(x => x.measurement), g => g.Select(x => x.measurementValue));

groups 是 Dictionary<IEnumerable<string>, Dictionary<IEnumerable<decimal>>


如何为所有键和值循环分组?我没弄明白。


foreach(var group in groups)

{

    //????

}


拉莫斯之舞
浏览 150回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP