不存在对';卡';从';卡';到IComparable
本文关键字:IComparable 不存在 | 更新日期: 2023-09-27 18:22:02
如何比较卡片列表?我得到这个错误,我不知道它意味着什么,也不知道如何修复它。我得到的错误:
类型"Card"不能用作泛型类型或方法"secondClass"中的类型参数"T"。没有隐含引用"Card"从"Card"转换为IComparable
class Node<T>
{
public int id;
public T data;
public Node<T> next;
}
class GameLinkedList<T> where T : IComparable
{
private Node<T> head;
private Node<T> temp;
private int count = 0;
public void AddFront(T t)
{
count++;
temp = head;
Node<T> node = new Node<T>();
node.data = t;
node.id = count;
node.next = temp;
head = node;
}
}
class Bundle
{
//private List<Card> deck1;
GameLinkedList<Card> deck = new GameLinkedList<Card>();
}
class Card
{
private Suit suit;
private Value value;
private string cardName;
}
您的Card
类需要实现IComparable
接口
MSDN