Download and install Xamarin Studio: Xamarin Studio
Open terminal and check commands:
mcs
mono
###################
mcs - C# compiler
mono - Mono runtime
Console example
Create file:
vim monoapp.cs
using System; // Importing namespace
class Test // Class declaration
{
static void Main() // Method declaration
{
//int x = 12 * 30; // Statement 1
Console.WriteLine ("Hello form mono!"); // Statement 2
} // End of method
}
Compile :
mcs monoapp.cs
And run:
mono monoapp.exe
Result:
Hello from mono!
WinForms UI example:
using System;
using System.Drawing;
using System.Windows.Forms;
public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}
public HelloWorld ()
{
Button b = new Button ();
b.Text = "Click Me!";
b.Click += new EventHandler (Button_Click);
Controls.Add (b);
}
private void Button_Click (object sender, EventArgs e)
{
MessageBox.Show ("Button Clicked!");
}
}
Compile and run:
mcs -pkg:dotnet win_mono_app.cs
And run:
mono win_mono_app.exe
Links: