You need to install mono-complete if you want to run software for Mono or Microsoft .NET which you are not installing from a Debian package.
Install mono-complete. In all currently supported versions of Ubuntu open the terminal and type:
sudo apt install mono-complete
Save your C# code in a file called hello.cs. Example hello.cs code is:
using System;
namespace Project_1 {
class MainClass {
public static void Main (string[] args) {
Console.WriteLine ("Hello World!");
Console.ReadKey ();
}
}
}
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.
The official .NET Core from Microsoft has been around since 2016. It's open source software and supports many platforms. Even Mono now shares some code with .NET Core so there's almost no reason to use Mono in 2018
True open source solution as of 2021, is still Mono, available at their site https://www.mono-project.com/ Microsoft's implementation unsurprisingly doesnt work well (slow, unresponsive) on Linux. This is to be expected as Microsoft is a long time nemesis of Linux and its free, open source nature. Stick with Mono it is still developed and easily installable. Download Instructions on included link
You need to install mono-complete if you want to run software for Mono or Microsoft .NET which you are not installing from a Debian package.
Install mono-complete. In all currently supported versions of Ubuntu open the terminal and type:
Save your C# code in a file called hello.cs. Example hello.cs code is:
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.
Run the hello.exe program with mono.
The results of running your program in step 6. should be:
Press Enter to exit back to a default terminal prompt.
Decompile the executable file.
You can use
mono
which isC#
implementation, having cross-platform support and is open source.Open terminal and install mono:
For Ubuntu 20.04 (Stable)
For Ubuntu 18.04
For Ubuntu 16.04
For Ubuntu 14.04
Then type
Create a sample
C#
file in the current directoryFor example you can use the following code:
Use any text editor like gedit, type the following code and save the file as
GoodDay.cs
The command to compile the code -
An executable file
GoodDay.exe
is generated.The command to execute the
.exe
file -The output will be -
The command to decompile the executable file -
The decompiled code information is saved in the newly generated file
GoodDay.txt
The official .NET Core from Microsoft has been around since 2016. It's open source software and supports many platforms. Even Mono now shares some code with .NET Core so there's almost no reason to use Mono in 2018
Just go to the official website to download and install. If you want to install from command line then visit Install .NET on Linux, specifically Install the .NET SDK or the .NET Runtime on Ubuntu. To install the SDK and runtime with apt use
You can also install with snap
True open source solution as of 2021, is still Mono, available at their site https://www.mono-project.com/ Microsoft's implementation unsurprisingly doesnt work well (slow, unresponsive) on Linux. This is to be expected as Microsoft is a long time nemesis of Linux and its free, open source nature. Stick with Mono it is still developed and easily installable. Download Instructions on included link