Install

sudo apt install mono-complete

Program

Shell/scripting csharp

csharp

Compiler

Compile a program file to program.exe with Mono C# Compiler

mcs program.cs

Examples

Compile and run a program

$ mcs helloworld.cs
./helloworld.cs

Visual Studio

Launching

The default program name is "program.exe", but you can rename it in launch.json. Then use CTRL-FT to launch it.

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "mono",
            "request": "launch",
            "program": "${workspaceRoot}/helloworld.exe",
            "cwd": "${workspaceRoot}"
        }
}

Extensions

ms-vscode.mono-debug

Compile with debug information: csc -debug Program.cs

Attach to a program: mono --debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:55555 Program.exe

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Mono",
            "request": "attach",
            "type": "mono",
            "address": "localhost",
            "port": 55555
        }
    ]
}