I am getting the following error when using a CustomObject to instantiate my generic priority queue. It is working well when I instantiate with integer. Can anyone help me figure out the issue.
The error is appearing on line:
PQueue<CustomObject> pq = new PQueue<CustomObject>();
Error CS0311: The type
Heap.CustomObject' cannot be used as typeT’ in the generic type or method
parameterHeap.PQueue<T>'. There isHeap.CustomObject’ to
no implicit reference conversion from
`System.IComparable’ (CS0311) (Heap)
Your generic constraint is requiring
IComparable<T>, but yourCustomObjectonly implementsIComparable. You need to implementIComparable<CustomObject>