TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
andrew woolgar
NA
9
540
ArgumentOutOfRangeException was unhandles error
May 9 2020 3:46 PM
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<Card> deck;
//list of all palying cards
public
DeckOfCards()
{
deck =
new
List<Card>(NUM_OF_CARDS);
}
public
List<Card> 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
Reply
Answers (
1
)
Unpivot multiple columns
Calculate the marks and gets its averages marks