首页 > 解决方案 > 这是对带有重复项的 SortedList 的合理使用吗

问题描述

我有以下代码来制作带有重复键的列表。列表最多为 150 项,键值为 0..100。

public SortedList<double, Sector> sectors;
// ...
double theKey = 100.0 - sortValue;
while (sectors.Keys.Contains(theKey)) theKey += 0.00001;
sectors.Add(theKey, newSector);

这是一个合理的技巧还是有更好的类可以使用?

标签: c#sortedlist

解决方案


推荐阅读