代码
public class Cost
{
public double cost;
public int id;
}
public class CostComparer : IComparer<Cost>
{
public int Compare(Cost x, Cost y)
{
if (x.cost - y.cost < 1e-10)
{
return -1;
}
else
{
return 1;
}
}
}
错误的写法:
SortedList<double> list = new SortedList<double>(new CostComparer());\\XX
SortedList<double, Cost> list =