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; // number of all cards
- private List
deck; //list of all palying cards - public DeckOfCards()
- {
- deck = new List
(NUM_OF_CARDS); - }
- public List
getDeck { get { return deck; } } //get current deck - //create deck of 24 cards: 6 values with 4 suits
- 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
Arvind KushwahaPosted May 10, 2020, 12:03 AM