Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the ReadLine () method NOT pause for user input?

I began to study C#, but I ran into a problem. The ReadLine() method does not pause for user input. I just started C#, and it works on other people's programs, so I have no idea why. I am using Xamarin on a Mac.

Here is an example code that does not work:

using System;

namespace LearningC
{
    public class LearningSharp
    {
        public static void Main (String[] args)
        {
            Console.WriteLine (Console.ReadLine ());
        }
    }
}
like image 653
user3477016 Avatar asked Nov 05 '25 21:11

user3477016


2 Answers

I found out the solution. Right click on your project and select Options. Then, select General under the Run tab and check "Pause console output" ("Run on external console" must be checked for this to work.)

like image 143
user3477016 Avatar answered Nov 07 '25 16:11

user3477016


Maybe your Project is set to be a Windows application. Right click on your Project name, click properties and change output type to Console Application.

like image 21
Orkun Bekar Avatar answered Nov 07 '25 15:11

Orkun Bekar