I have the following code:
public class Graph<TNode> where TNode : IComparable<TNode>, IEquatable<TNode>
{
private ISet<Node<TNode>> _nodes;
private IDictionary<Node<TNode>, ISet<Tuple<Node<TNode>, long>>> _adjacencyList;
public Graph()
{
_nodes = new HashSet<Node<TNode>>();
_adjacencyList = new Dictionary<Node<TNode>, HashSet<Tuple<Node<TNode>, long>>>();
}
}
The compiler complains at the part, where I try to instantiate the _adjacencyList
Dictionary. It says that it cannot implicitly convert one type to the other. I was wondering, why is that? If I change the ISet
in the Dictionary's key to a HashSet
, everything works fine.