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

  • Home
  • SEARCH
  • 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 8739453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:56:25+00:00 2026-06-13T10:56:25+00:00

So right now I have a class called Clans which list several different clans

  • 0

So right now I have a class called “Clans” which list several different clans by name and their respective village.

    static void Main(string[] args)
    {
        Clan Uchiha = new Clan("Uchiha", "Konoha");
    }

And this basically goes on for a couple of more clans. It’s defined with two strings, Clan and Village. This is a GUI application, so when I click a button I want it to pick a random “Clan” which will display the Clan and their Village. Mind you I’m a complete newbie when it comes to thinking of projects on my own. I know how to do a click event but I’m not really sure how I make it so the button being clicked outputs information into the Clan and Village text box.

  • 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-13T10:56:26+00:00Added an answer on June 13, 2026 at 10:56 am

    I won’t be able to do this with the class Clan as I don’t have this defined. So, I’ll use List<string> instead if you don’t mind but at this point Clan must be a collection 🙂

    We’ll use Random and List<string> to sort this out.

    First, we must have some items in our collection List<string>. Let us create List<string> first using the following code

    List<string> Clans = new List<string>();
    

    Then, let’s add some items to Clans

    Clans.Add("Uchiha,Konoha");
    Clans.Add("Picrofo Groups,Egypt");
    Clans.Add("Another Clan,Earth");
    Clans.Add("A fourth Clan,Somewhere else");
    

    Now, we we’ll need to output an item of these when the button is clicked knowing that there’s a splitter , that splits the first value from the second value in each item. For example. Uchiha which is the name of the clan and the first value is separated from Konoha which is the location of the clan and the second value by , which is the splitter. We’ll need to create the Random class as well. Let’s try this

    Random Rand = new Random(); //Create a new Random class
    int Index = Rand.Next(0, Clans.Count); //Pick up an item randomly where the minimum index is 0 and the maximum index represents the items count of Clans
    string[] Categorizer = Clans[Index].Split(','); //Split the item number (Index) in Clans by ,
    MessageBox.Show("Name:" + Categorizer[0] +" | Location: "+ Categorizer[1]); //Output the following
    

    Finally, it would look like this in your form class

        List<string> Clans = new List<string>();
        private void Form1_Load(object sender, EventArgs e)
        {
            Clans.Add("Uchiha,Konoha");
            Clans.Add("Picrofo Groups,Egypt");
            Clans.Add("Another Clan,Earth");
            Clans.Add("A fourth Clan,Somewhere else");
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
              Random Rand = new Random();
              int Index = Rand.Next(0, Clans.Count);
              string[] Categorizer = Clans[Index].Split(',');
              MessageBox.Show("Name:" + Categorizer[0] +" | Location: "+ Categorizer[1]);
        }
    

    Thanks,

    I hope you find this helpful 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have a function, in a class that is used to listen
I'm in a mobile programming class right now and we have to make a
I have create my own NSOpenGLView class, right now the data that i want
I have always been kind of confused by threads, and my class right now
Right now I'm working with a copy constructor for taking a list called val
I have a singleton class called playbackhelper to which I want to add a
Right now im using a function in my sprite class called SetTextureColour: public void
So, I'm writing a program for Android. Right now, I'm in a class called
I have a a class called ViewFactory and this class should deliver the right
I have a class called AbstractBook , which has a property: @property(strong) AbstractPage *page;

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.