Step 1: Environment Ubuntu)
Sudo apt-get install mono-gmcs mono
Step 2: Create example. cs
Class X {
Static void Main (){
System. Console. Write ("My first mono app worked! \ N ");
}
}
Step 3 compile
Gmcs example. cs
Step 4
./Example.exe
Use C # Fedora in Linux)
When Microsoft launched its. NET strategy, one of the goals was to run the software on a variety of different platforms.
Mono, an open-source project that enables. NET to run on your Linux operating system.
If you work with Microsoft and Linux like me, this Mono will help you and me. You can write C # programs on both platforms.
Download the latest Mono installation package from the www.go-mono.com. I read it. When I wrote this article, Mono 1.1.13.8 was the latest Stable version on the official website.
Before installing Mono, you must determine whether you have GIMP Toolkit, Drawing Kit, and pkg-config. You can download them on rpmfind.net. We recommend that you download the latest version. If you have these software on Linux, you may need to upgrade them.
Install the software below:
# Rpm-Uvh glib2-2.0.0-1.i386.rpm
# Rpm-Uvh glib2-devel-2.0.0-1.i386.rpm
# Rpm-Uvh pkgconfig-0.12.0-1.i386.rpm
Next, extract Mono:
# Tar-zxvf mono-1.1.13.8.tar.gz
Next:
#./Configure
# Make
# Make install
After all the above is done, your Linux system will have a working Mono, which includes the Mono C # compiler, Mono instant compiler, and mintThe Mono interpreter ). Now you can write C # program. For example, hey, write the most famous Hellow World Program:
Class Hello {
Static void Main (){
System. Console. WriteLine ("Hello World ");
}
}
Haha, it is really a classic. C # the program must be suffixed with. cs. Enter the program and save it. For example, save it as HelloWorld. cs and compile it:
# Mcs Hello. cs
If you write all programs, this command will generate a MSIL file named helloworld.exe, and then you can use this file:
# Mint HelloWorld.exe
Hello World
Mint interprter has many optional commands, including -- trace and -- debug, which are useful for debugging. When your program has been completed, you can compile it on the JIT compiler:
# Mono HelloWorld.exe
Hello World
The public Language Runtime Library provides cross-platform capabilities .. . NET program can run on any system with CLR installed. In fact, the C # compiler of Mono is compiled on the Windows platform using the Microsoft. NET Framework SDK and then moved to the Linux platform. You can convert the compiled program on Windows to Linux and run it.
Mono has not fully implemented the. NET Framework, but it is enough for you to run the program you want to write. Open-source things generally evolve quickly, and may soon be able to fully meet your needs.
By the way, there is a Gtk # project on the gtk-sharp.sourceforge.net, which is committed to binding gtk + toolkit to the C # language. It is also designed to provide libraries compatible with Windows. Forms under Mono. Of course, it is difficult to migrate from Windows to Linux. Let's keep an eye on its progress.