You need to add a restriction classon the Tclass type argument Graph<T>:
public class Graph<T> where T : class, IPoint
This is because covariance does not work with structs:
new List<Int32>() is IEnumerable<IConvertible> == false
new List<String>() is IEnumerable<IConvertible> == true
although both Int32and Stringimplement IConvertible.
See Why covariance and contravariance do not support value type .
source
share