Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8297891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:34:08+00:00 2026-06-08T15:34:08+00:00

Hi guys i need some help here i want to distribute 6 strings randomly

  • 0

Hi guys i need some help here i want to distribute 6 strings randomly in 6 buttons as text without any repetition. That is i Want to do some kind of shuffling and distribute it but there will no duplicates each button will hold a unique string. If anyone could post the code it would be great 🙂 Thank you

class Card_Deck
{
    public Random r;
    public string ReceiveCards()
    {
        List<string> cards = new List<string>();
        cards.Add("♣ King");
        cards.Add("♦ King");
        cards.Add("♥ King");
        cards.Add("♠ King");
        cards.Add("♣ Jack");
        cards.Add("♦ Jack");

        int index = r.Next(cards.Count);
        var card = cards[index];
        cards.RemoveAt(index);
        return card;

    }
}

}

This is in the main form

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Card_Deck cd = new Card_Deck() { r = new Random(DateTime.Now.Millisecond) };

        button1.Text = cd.ReceiveCards();
        button2.Text = cd.ReceiveCards();
        button3.Text = cd.ReceiveCards();
        button4.Text = cd.ReceiveCards();
        button5.Text = cd.ReceiveCards();
        button6.Text = cd.ReceiveCards();
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:34:10+00:00Added an answer on June 8, 2026 at 3:34 pm

    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 "";
                }
    
            }
        } 
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys i need some help here , im getting this error here at the
hi all i need some help from you guys.. well here's the description Guys
hi guys i need some help here^^ i got a tag <html> <head> function
Hi guys I need some help here, to my bad thinking brain : I
i Guys I need some help with some Regular expression: here is the string:
hello guys i need to sort some elements of integer in an integer array
Hie guys i need help with my code. I have a form where a
Heythere. I need your guys help with file renaming using a .bat file. I
Sorry guys for noob question, need help. I'm try to use Sharekit - https://github.com/ShareKit/ShareKit
Hay guys, i need help with a REGEX. I have the got the value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.