Gid day all,
I am still learning C#
I have been seeking to modify an poker game tutorial from using an array to using a list for the deck of cards.
- class DeckOfCards : Card
- {
- const int NUM_OF_CARDS = 24;
- private List<Card> deck;
- public DeckOfCards()
- {
- deck = new List<Card>(NUM_OF_CARDS);
- }
- public List<Card> getDeck { get { return deck; } }
-
- public void setUpDeck()
- {
- int i = 0;
- foreach(SUIT s in Enum.GetValues(typeof(SUIT)))
- {
- foreach (VALUE v in Enum.GetValues(typeof(VALUE)))
- {
- deck[i] = new Card { MySuit = s, MyValue = v };
- i++;
- }
- }
- ShuffleCards();
- }
I keeping getting ArgumentOutOfRangeException was unhandles error for deck[i] =new Card { MySuit = s, MyValue = v};
How do I change the argument for array to issue
Thank you for help in advance