lundi 17 juillet 2017

C# - How do i guess a random number and then use it?

How do i make a random to an int to use it afterwards?

        Console.Write("How old am i? Guess!");
        string randomguess = Console.ReadLine();
        Console.WriteLine("My age is " + (random.Next(1, 101)));
        int newrandomguess = Convert.ToInt32(randomguess);

        if(newrandomguess == random)
        {
            Console.WriteLine("Oh you guessed my age correctly! Im surprised.");
        }
        else
        {
            Console.WriteLine("As i expected, u guessed wrong..");
        }




Aucun commentaire:

Enregistrer un commentaire