【发布时间】:2021-05-29 11:34:53
【问题描述】:
我试图制作一本字典,但它会使用一对整数作为键。
public Dictionary<int[], car> listOfCells = new Dictionary<int[], car>();
但是当我检查是否有一个值时,它总是返回 false
return listOfCells.ContainsKey(new int[] { x, y })
【问题讨论】:
-
您应该以
public Dictionary<int, int[]> listOfCells = new Dictionary<int, int[]>();的方式创建字典,其中键将是汽车的一些唯一标识符
标签: c# dictionary