Ubuntu terminal not waiting for Console.ReadKey() input

You need to install mono-complete instead of Mono development tools (mono-devel) package if you want to run software for Mono or Microsoft .NET which you are not installing from a Debian package.


  1. Install mono-complete

     sudo apt-get install mono-complete
    
  2. Save your C# code in a file called hello.cs.

  3. Make hello.cs executable. Right-click the hello.cs file -> select Properties -> Permissions tab -> put a check mark to the left of Allow executing file as program.

  4. Change directories using the cd command to the directory that contains the hello.cs file.

  5. Use the mcs compiler and create a Windows executable named hello.exe from the source hello.cs.

     mcs -out:hello.exe hello.cs
    
  6. Run the hello.exe program with mono.

     mono hello.exe
    
  7. The results of running your program in step 6. should be:

     Hello World!  
    
  8. Press Enter to exit back to a default terminal prompt.

Run C# program in MonoDevelop

  1. Install MonoDevelop

     sudo apt-get install monodevelop # 17.10 and earlier
    
  2. Open MonoDevelop application.

  3. Create a new project. Select File -> New -> Solution -> .NET -> Console Project -> check the dropdown menu next to Console Project to make sure that C# is selected -> click the Next button -> select a name and directory location for your project -> click the Create button.

  4. In the left pane select Program.cs. Copy your C# code into Program.cs.

  5. Select Build -> Build All.

  6. Click the Run arrow in the upper left corner of MonoDevelop to run the program.