I have a button on my windows form which add five random cards to my list. The random cards are displayed in a listbox. When I first press the button, the listbox show 5 random cards. When I press the button again, the listbox shows the same 5 random cards 3 times now. Instead of 10 random cards. Is there anyway to get rid of this problem?
private void RandomButton_Click(object sender, EventArgs e)
{
Random random = new Random();
for (int i = 0; i < 5; i = i + 1)
fiveRandomCards.Add(new Card((Symbool)random.Next(1, 4), (Waarde)random.Next(1, 14)));
foreach (Card card in fiveRandomCards)
CardsLB.Items.Add(card.name);
}