西装是卡中的4个符号,西装是卡的13个数字和字母。我很困惑的HashTable多维数组混淆?
cardsInSuit.Add(value, new PlayingCard(suit, value));
难道说把价值在游戏牌(西装,价值)?然后在this.cardPack.Add(suit,cardsInSuit)上;由于hashTable全部是线性的。我将这看作是suit = 0,cardsInSuit是指向另一个0-12线性数组的值。我对么?。
class Pack
{
private Hashtable cardPack; // no need to specify
private PlayingCard[,] cardPack;
public Pack()
{
this.cardPack = new Hashtable();
for (Suit suit = Suit.Clubs; suit <= Suit.Spades; suit++) // outer loop
{
SortedList cardsInSuit = new SortedList(); // sorted list makes 2 array
for (Value value = Value.Two; value <= Value.Ace; value++)
{
cardsInSuit.Add(value, new PlayingCard(suit, value));
}
this.cardPack.Add(suit, cardsInSuit);
}
}
您有两个名为'cardPack'(一个是'Hashtable',一个是'PlayingCard'的二维数组)的字段。这不会编译 - 你是否正确地复制代码? – Justin