Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# file - output type: console

I wrote a code, and the line

string thing = Console.ReadLine();

causes a problem. Xamarin shows me that it did not read in the input this command, so the variable thing becomes null.

I found from other questions and answers here that there are two output types of an application, Window and Console. So, mine probably is not the second one.

But I can't find how to switch to console. I have the latest MonoDevelop and Xamarin, and yet this problem remains. Does anyone know what could help?

Any advice will be highly appreciated!

like image 463
Lochness Monster Avatar asked Mar 31 '13 00:03

Lochness Monster


2 Answers

Rob G Pretty much has it so I'm not sure why you can't see it. Here's the click-by-click for completeness.

For console output from Xamarin:

Right click the project you have set as startup project, then do:

Options >> Expand 'Run' >> General >> Check 'Run on external console'

Once this is set, execution will halt on Console.ReadLine();

There is no need to check the 'Pause console output' checkbox. This simply holds the console open at the end of execution with a 'Press any key to continue...'.

like image 77
Chris Wallis Avatar answered Sep 30 '22 00:09

Chris Wallis


Try right clicking on the "options" list item on the menu for your project and making sure Run on external console is marked. It's in the Run -> General tab, I think.

like image 29
Rob G Avatar answered Sep 29 '22 23:09

Rob G