How to run C# from command line
Installing compiler
The easiest way is to install MonoDevelop
from https://www.monodevelop.com/.
File extension
Standard extension for C# code is .cs
. So one can create Hello.cs
file with
using System;
namespace HelloWorld
{
class Hello
{
static void Main()
{
Console.WriteLine("Hello World!");
}
}
}
Compile and run
In order to compile one has to write
mcs Hello.cs
and in order to run:
mono Hello.exe