Reading an integer from user input

后端 未结 11 910
时光取名叫无心
时光取名叫无心 2020-11-22 09:44

What I am looking for is how to read an integer that was given by the user from the command line (console project). I primarily know C++ and have started down the C# path. I

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 09:52

    I used int intTemp = Convert.ToInt32(Console.ReadLine()); and it worked well, here's my example:

            int balance = 10000;
            int retrieve = 0;
            Console.Write("Hello, write the amount you want to retrieve: ");
            retrieve = Convert.ToInt32(Console.ReadLine());
    

提交回复
热议问题