mardi 9 juin 2015

Writing a GetRandomNumber Method

I'm writing in Windows Form Application

I'm trying to write a method(function) named GetRandom Number that will be called from the go button.

This function should return a random number that is equal to or falls between the two numbers entered into the input controls(textboxes).

    private void BtnGo_Click(object sender, EventArgs e)
    {


    int getRandomNumber(int 2, int 50)
        {
            Random randomNumber = new Random();

            if (2 - 50 > 0)
            {
                return randomNumber.Next(0, 10);
            }
            else if (50 - 2 > 0)
            {
                return randomNumber.Next(50, 2);
            }
            else
            {
                return 2;
            }
        }




Aucun commentaire:

Enregistrer un commentaire