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.
-
Install mono-complete
sudo apt-get install mono-complete
-
Save your C# code in a file called hello.cs.
-
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.
-
Change directories using the
cd
command to the directory that contains the hello.cs file. -
Use the mcs compiler and create a Windows executable named hello.exe from the source hello.cs.
mcs -out:hello.exe hello.cs
-
Run the hello.exe program with mono.
mono hello.exe
-
The results of running your program in step 6. should be:
Hello World!
-
Press Enter to exit back to a default terminal prompt.
Run C# program in MonoDevelop
-
Install MonoDevelop
sudo apt-get install monodevelop # 17.10 and earlier
-
Open MonoDevelop application.
-
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.
-
In the left pane select Program.cs. Copy your C# code into Program.cs.
-
Select Build -> Build All.
-
Click the Run arrow ▶ in the upper left corner of MonoDevelop to run the program.