mercredi 9 août 2017

C#: Output a random element of a list into specific textboxes

I set my goal to learn a bit of C# this vacation. I already have limited knowledge of C and some C# Console commands.

Anyways since my sister likes to draw a lot, I thought I could make myself a program which outputs a random element of a list into the specific textbox.

The program in question

If I press the button, every textBox should now contain a random element of each List specific to their category. So textBox 3 should output an element of the Body List.

List <string> Sex = new List<string>;
        Sex.Add("Male");
        Sex.Add("Female");

        List <string> Head = new List<string>;
        Head.Add("Square");
        Head.Add("Tall");
        Head.Add("Wide");
        Head.Add("Petite");
        Head.Add("Unproportional");
        Head.Add("Triangle");
        Head.Add("Round");
        Head.Add("Diamond");
        Head.Add("Huge");
        Head.Add("Odd");

        List <string> Body = new List<string>;
        Body.Add("Fat");
        Body.Add("Slim");
        Body.Add("Petite");
        Body.Add("Skinny");
        Body.Add("Muscular");
        Body.Add("Tall");
        Body.Add("Lanky");
        Body.Add("Model");

        List <string> Features = new List<string>;
        Features.Add("Cane");
        Features.Add("Gun");
        Features.Add("Sword");
        Features.Add("Shield");
        Features.Add("Lunchbox");
        Features.Add("Pet");
        Features.Add("Armor");
        Features.Add("Dragon Head");
        Features.Add("Ghettoblaster");
        Features.Add("Giant Sausage");
        Features.Add("Backpack");

        List <string> Time = new List<string>;
        Time.Add("Victorian");
        Time.Add("Roman");
        Time.Add("Future");
        Time.Add("Present");
        Time.Add("Mesozoic Era");
        Time.Add("World War I");
        Time.Add("World War II");

        List <string> Setting = new List<string>;
        Setting.Add("Caught stealing");
        Setting.Add("Fighting");
        Setting.Add("Sneaking into a mansion");
        Setting.Add("Swimming");
        Setting.Add("Talking to a police officer");
        Setting.Add("Making music");
        Setting.Add("Drawing");
        Setting.Add("In a lonely forest");

So how would I do this? I tried using the Random function but I don't quite understand how it works.

I hope you can help me and understand what I want, English isn't my main language, thanks!




Aucun commentaire:

Enregistrer un commentaire