Reputation: 179
as the title says, i have an array of hashsets, but i don't know how apply to them a comparer. Like this:
//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];
Of Course i need the comparer.. What am i doing wrong? Thank you
Upvotes: 5
Views: 2434
Reputation: 149538
You have an array of HashSet<T>
, you need to initialize each element in the array:
for (int i = 0; i < UpdateList.Length; i++)
{
UpdateList[i] = new HashSet<AnimalCell>(new CellComparer());
}
Upvotes: 5