我有一个类型Card
,其int
属性称为Value
where Ace = 14, Five = 5 等。
如果我有一张卡片列表(5),即。一只手。我想做的是计算Value
等于另一张卡的数字卡,即找到 4 种,3 种,一对,两对等。我对 C#/编程相当陌生,但我相信这是 LINQ/Lambda 表达式的情况吗?有人可以帮我吗?
class Card : IComparable<Card>
{
private string name;
private int value;
private string suit;
public int Value
{
get
{
return value;
}
}
<.....>
//Constructor accepts string ex. "AH" and builds value 14, suit "Hearts"
public int CompareTo(Card that)
{
if (this.value > that.value) return -1;
if (this.value == that.value) return 0;
return 1;
}
}
List<Card> HandBuilder = new List<Card>();
HandBuilder.Add(...); //5 Cards
HandBuilder.Count ?? //Help