vendredi 19 juillet 2019

scanner in while loop

private int scanner = Convert.ToInt32(Console.ReadLine());
public void Play()
        {
            while (true)
            {
                if (scanner > theNumber)
                {
                    Console.WriteLine("your number is too big");
                } else 
                if (scanner < theNumber)
                {
                    Console.WriteLine("your number is too big");
                }  else
                {
                    Console.WriteLine("you got it");
                    break;
                }
            }
        }

this is a simple game where I need to iterate thr same number through the set of if statements. in Java they use

int x;

x = scn.nextInt();

What can I use in C#? There is no scanner.

Aucun commentaire:

Enregistrer un commentaire