You are currently viewing the BOOK: Beginning Visual C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
8 class Program
10 static void Main(string args)
12 Deck myDeck = new Deck();
14 for (int i = 0; i < 52; i++)
16 Card tempCard = myDeck.GetCard(i);
18 if (i != 51)
19 Console.Write(", ");
public Card GetCard(int cardNum)
if (cardNum >= 0 && cardNum <= 51)
throw (new System.ArgumentOutOfRangeException("cardNum", cardNum, "Value must be between 0 and 51."));
on line 16 Card tempCard = myDeck.GetCard(i);
GetCard return cards[cardNum]
how do you assign value of cards[cardNum] to tempCard? isn't tempCard is the variable type of Card?
If I understand your post correctly, the method GetCard does not return a Cards object. It returns a Card object from within the internal Cards collection of Deck. cards[cardNum] returns a Card object at the position within cards specified by cardNum.