1

I made a c# program, on visual studio, that asks the user for their name and then prints it out. I ran it but I unchecked "run on external console". However when the program asks for my name, i cannot type it in the application output. So i checked the run on external console but now, when i run it, it just opens a blank terminal page.

Here is the code:

  using System;

  namespace ErrorTypes
  {
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("What is your name?: ");
            string name = Console.ReadLine();
            Console.WriteLine("Welcome {0}", name);
        }
    }
  }

I am on macOS.

Thanks,

Lex Li
  • 60,503
  • 9
  • 116
  • 147
  • Runs fine for me on MacOS Catalina, Visual Studio for Mac Community 8.3.11. I don't see an option "run on external console" perhaps you are using Visual Studio Code? – iakobski Dec 27 '19 at 20:45
  • Does this answer your question? [Visual studio (MAC) Console Application](https://stackoverflow.com/questions/40690871/visual-studio-mac-console-application) – Jawad Dec 27 '19 at 20:48
  • yeah but the thing is that when i click run on external console, it is supposed to open terminal and run it directly. For me, it just opens a blank terminal page – Mariohead13 Dec 27 '19 at 20:59
  • If right click on the project name, then go to options, then go to run -> default, you will see run from an external console. I am also on Macos catalina but I am using Visual studio. – Mariohead13 Dec 27 '19 at 21:00
  • Visual Studio for Mac didn't implement a builtin console, so your wish won't come true yet. Please stick to the external console. – Lex Li Dec 27 '19 at 22:47
  • What do you mean by that? I am sticking to the external console(terminal) – Mariohead13 Dec 27 '19 at 22:55
  • @lex li Do you know a way to input into the program? I cannot do it unless i check the "run on external console". So when terminal pops up, do you know a way to run the c# code? – Mariohead13 Dec 28 '19 at 19:03
  • Cannot reproduce "it just opens a blank terminal page", so unless you provide more information (macOS version, and VS for Mac version) it is not possible to discuss. Also notice that very likely you need to be on latest of both, and also reboot the machine. That often resolves miserable issues. – Lex Li Dec 28 '19 at 19:10
  • @lex li How do Macintosh users get input from a visual studio program? Because I want to know the commands to be able to run the c# program from the terminal. On windows, when you check "run from external console" and you run the program, it just opens up the command prompt and runs it directly without any commands. For me however, it opens up a terminal page but does not run it. So I need to type in the commands to run the visual studio code, however I do not know those commands, I have searched online but I didn't find anything. Thx – Mariohead13 Dec 28 '19 at 19:40
  • lol............ – Mariohead13 Dec 28 '19 at 21:26
  • @Mariohead13 - To run a .NET framework console project on the Mac from the command line you would use `mono path/to/yourapp.exe`. For a .NET Core console project you would use either `dotnet run` or `dotnet path/to/yourapp.exe`. With Visual Studio for Mac can you look in the IDE log (Help - Open Log Directory) to see if there is an error reported about the terminal window? – Matt Ward Dec 30 '19 at 12:57
  • @Matt Ward Thank you so much, it worked, I typed dotnet run and it succesfully ran the program. Thank you – Mariohead13 Jan 04 '20 at 20:35

0 Answers0