[英]C# priority queue, generic type <T> conversion
public class PriorityQueue<T> : IPriorityQueue<T>
where T : IComparable
So, I've made a priority queue class with the Header above and I'm attempting to use it with another class. 因此,我已经在上面的Header中创建了一个优先级队列类,并且尝试将其与另一个类一起使用。
private static PriorityQueue<Order> PQ;
It seems like this should work perfectly fine, but I'm receiving this error. 看来这应该工作得很好,但是我收到此错误。
My
namespace.Order
cannot be used as type parameterT
in the generic methodnamespace.PriorityQueue<T>
.我的
namespace.Order
不能用作泛型方法namespace.PriorityQueue<T>
中的类型参数T
There is no implicit conversion fromnamespace.Order
toSystem.IComparable
从
namespace.Order
到System.IComparable
没有隐式转换
I can't really discern what that is telling me to do. 我真的无法辨别那是什么告诉我要做的。 Does this mean that my
IComparable
implementation isn't sufficient for this purpose, or is it some sort of bad syntax I'm using? 这是否意味着我的
IComparable
实现不足以实现此目的,还是我使用的某种语法错误?
它说,您的通用类型参数(即Order
类型)应实现IComparable接口。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.