[英]Array of HashSets with comparer in C#
如标题所示,我有一组哈希集,但我不知道比较器如何应用于它们。 像这样:
//This Works:
public HashSet<Animal.AnimalCell>UpdateList = new HashSet<Animal.AnimalCell>(new CellComparer());
//This Does not work:
public HashSet<Animal.AnimalCell>[]UpdateListThreaded = new HashSet<Animal.AnimalCell>(new CellComparer())[10];
//This Does not Work :
public HashSet<Animal.AnimalCell>[]UpdateListThreaded = new HashSet<Animal.AnimalCell>[10](new CellComparer());
//This Works:
public HashSet<Animal.AnimalCell>[]UpdateListThreaded = new HashSet<Animal.AnimalCell>[10];
当然我需要比较器..我在做什么错? 谢谢
您有一个HashSet<T>
数组,您需要初始化数组中的每个元素:
for (int i = 0; i < UpdateList.Length; i++)
{
UpdateList[i] = new HashSet<AnimalCell>(new CellComparer());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.