Yan*_*ann 5 c# arrays hashset icomparer
正如标题所说,我有一组hashsets,但我不知道如何将它们应用于比较器.像这样:
//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];
Run Code Online (Sandbox Code Playgroud)
当然我需要比较器..我做错了什么?谢谢
你有一个数组HashSet<T>,你需要初始化数组中的每个元素:
for (int i = 0; i < UpdateList.Length; i++)
{
UpdateList[i] = new HashSet<AnimalCell>(new CellComparer());
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
778 次 |
| 最近记录: |