我有一个包含整数和元组的字典。
我想在实例化时插入一些值,但出现错误:
无法从“ System.Tuple”转换为“ System.Collections.Generic.IEqualtyComparer”
这就是我想要做的:
public static readonly Dictionary<int, Tuple<int, double>> DIAMETER_METRIC_CHAMFER
= new Dictionary<int, Tuple<int, double>>({80, new Tuple<int, double>(16, 37.0)}
);
答案 0 :(得分:7)
您已将元素{80, new Tuple<int, double>(16, 37.0)}
传递到字典的构造函数中,而应使用初始化程序:
public static readonly Dictionary<int, Tuple<int, double>> DIAMETER_METRIC_CHAMFER
= new Dictionary<int, Tuple<int, double>>()
{
{ 80, new Tuple<int, double>(16, 37.0) }
};