J
James
Hi there,
I've have a class called Edge, with the following signature:
class Edge : IComparable{
....
....
....
}
And another class called CompareEdge, with the following signature:
class CompareEdge<T> : IComparer<T> where T : IComparable<T>
{
....
....
....
}
However, In my test class, the following statement is not compiling:
CompareEdge<Edge> comparer = new CompareEdge<Edge>();
I'm getting the following error:
"The type 'MetroNetwork.Edge' cannot be used as type parameter 'T' in the
generic type or method 'MetroNetwork.CompareEdge<T>'. There is no implicit
reference conversion from 'MetroNetwork.Edge' to
'System.IComparable<MetroNetwork.Edge>'."
Can someone please educate me as to why this is NOT compiling and how to fix
it?
Many thanks,
J
I've have a class called Edge, with the following signature:
class Edge : IComparable{
....
....
....
}
And another class called CompareEdge, with the following signature:
class CompareEdge<T> : IComparer<T> where T : IComparable<T>
{
....
....
....
}
However, In my test class, the following statement is not compiling:
CompareEdge<Edge> comparer = new CompareEdge<Edge>();
I'm getting the following error:
"The type 'MetroNetwork.Edge' cannot be used as type parameter 'T' in the
generic type or method 'MetroNetwork.CompareEdge<T>'. There is no implicit
reference conversion from 'MetroNetwork.Edge' to
'System.IComparable<MetroNetwork.Edge>'."
Can someone please educate me as to why this is NOT compiling and how to fix
it?
Many thanks,
J