对复杂字典Dictionary<T1,T2>排序问题


//VoltageCount类(电压值对应的数量):
    public class VoltageCount
    {
        public Double Voltage { get; set; } //电压值
        public int CountV { get; set; } //电压值对应的数量
        public VoltageCount()
        {
        }

        public VoltageCount(Double voltage, int countV)
        {
            this.Voltage = voltage;
            this.CountV = countV;
        }
    }

Dictionary<Point, VoltageCount>是将坐标点(绘制图像时使用)与VoltageCount数据对应的字典,目的用来在绘图对象(Graphics)中绘制电压值-数量的对应图像(如图中右侧部分)。

由于同时需要按数量大小进行排序,以便输出表格(如图中左边两表格,分别按数量降序排列),所以这里涉及字典排序问题。

            Dictionary<Point, VoltageCount> result = new Dictionary<Point, VoltageCount>();

                for (int i = 0; i <= 4; i++)
                {
                    result.Add(listHeatPoints[i], dictionaryPointVoltageCount[listHeatPoints[i]]);

                }

//排序

            Dictionary<Point, VoltageCount> dicSort = result. OrderByDescending(s => s.Value.CountV)

                .ToDictionary(pair => pair.Key, pair => pair.Value);



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值