DEV Community

dwarfŧ
dwarfŧ

Posted on

17

getting started with c# on linux

step 1
i am using ubuntu, which is a debian based linux distro. I installed it with:

wget -nv https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt install snapd
sudo service snapd start
sudo snap install dotnet-sdk --classic
sudo apt-get install mono-complete

Enter fullscreen mode Exit fullscreen mode

WARNING: this will only work with debian, please find how to install c# on your linux distro.

step 2
next we can create a main.cs file. The .cs extension is c# files. here is a hello world program:

using System;

public class main {
  public static void Main(String[] args){
    Console.WriteLine("Hello, World!");
  }
}
Enter fullscreen mode Exit fullscreen mode

this will log "Hello, World!" into the terminal.

step 3
compiling on linux is a bit different. In step 1 we install c#. This allows us to compile c# code. to compile we can do: mcs main.cs this will give us a main.exe file. Don't worry! This isn't a windows exe file because then we wouldn't be able to execute it. No, this is just a standard machine code file which we can execute by doing: ./main.exe And done! It will output or hello world program!

step 4
enjoy and keep on coding.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay