lundi 8 mai 2017

How to generate random numbers from a range in c# [duplicate]

This question already has an answer here:

So I need to generate random numbers based on user set parameters, and make a basic math expression. They have 3 options; single, double, or triple digit numbers. So based on that I need to generate a random number from 0 to 9, 0 to 99, and 0 to 100.

So far I've read about the Random class, but i have no idea how to use it and im pretty confused. I'm new to c# pls dont roast. This is my poor attempt:

` Random rnd = new Random();
        int value = 0;

        if (digits == 1)
        {
            rnd.Next(value);
            q1Lbl.Text = value.ToString();
        }`

I know, I know. It doesn't make any sense, but this thing is due in 3 days so I just need a solution. q1Lbl is the lable where one number will be displayed, obviously there is going to have to be another number on the other side.

Last time I asked a question I got flamed real hard, I'm just need to pass my class, friends. I wouldn't ask unless I really needed it.

Thanks a lot!




Aucun commentaire:

Enregistrer un commentaire