public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void button1_Click(object sender, EventArgs e) { label1.Text = Card_Deck.ReceiveCards(); } private void button2_Click(object sender, EventArgs e) { label2.Text = Card_Deck.ReceiveCards(); } private void button3_Click(object sender, EventArgs e) { label3.Text = Card_Deck.ReceiveCards(); } private void button4_Click(object sender, EventArgs e) { label4.Text = Card_Deck.ReceiveCards(); } private void button5_Click(object sender, EventArgs e) { label5.Text = Card_Deck.ReceiveCards(); } private void button6_Click(object sender, EventArgs e) { label6.Text = Card_Deck.ReceiveCards(); } class Card_Deck { public static Random r = new Random(); private static List<string> cards = new List<string>() { "♣ King 1", "♦ King 2", "♥ King 3", "♠ King 4", "♣ Jack 5", "♦ Jack 6" }; public static string ReceiveCards() { if (cards.Count > 0) { int index = r.Next(cards.Count); var card = cards[index]; cards.RemoveAt(index); return card; } else { return ""; } } } }
1
solved C# Randomly distributing strings without repetiotion [closed]