Reputation:
public override ISet<string> SetCellContents(string name)
{
HashSet<String> list = graph.GetDependents(name);
return list;
}
Graph.getDependents(name)
returns an IEnumerable
of a HashSet<String>
. I get an error:
"cannot convert from IEnumerable to ISet"
I am not sure what to do?
Upvotes: 2
Views: 1958
Reputation: 37299
You should instantiate a new HashSet
and pass it the graph.GetDependents(name)
as input. In addition as GetDependents
returns IEnumerable<HashSet<string>>
then use SelectMany
to flatten the inner collections before creating the new HashSet
"
public override ISet<string> SetCellContents(string name)
{
return new HashSet<string>(graph.GetDependents(name).SelectMany(hs => hs));
}
As a side note using the name list
for something that is not a List<T>
(or in general) is not a good practice. You could use something like dependenciesSet
instead.
Upvotes: 5