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.
I won’t be able to do this with the class
Clanas I don’t have this defined. So, I’ll useList<string>instead if you don’t mind but at this pointClanmust be a collection 🙂We’ll use
RandomandList<string>to sort this out.First, we must have some items in our collection
List<string>. Let us createList<string>first using the following codeThen, let’s add some items to
ClansNow, 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.Uchihawhich is the name of the clan and the first value is separated fromKonohawhich 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 thisFinally, it would look like this in your form class
Thanks,
I hope you find this helpful 🙂