How to Install C# on Ubuntu 22.04 and Getting Started
C Sharp is a strong-typed, multi-paradigm programming language developed by Microsoft as part of the .NET platform.
C# is a strong-typed, multi-paradigm programming language developed by Microsoft as part of the .NET platform.
Its syntax is object-oriented and was based on C++ but includes many influences from other programming languages, such as Object Pascal and, mainly, Java.
In this article we will see how to install on Ubuntu22.04, however, you can adapt the instructions for any other version or even another distribution.
Installation
Before installing, register the keys:
Now install the key:
Tip: execute one command at a time, if your Ubuntu version is different, find 22.04 for the version corresponding to yours. See here all available versions.
Now install the SDK, runtime will also be installed automatically
You can now clean the file: packages-microsoft-prod.deb
Testing a Hello, World!
1. Create a project
If you want to specify the version, use: dotnet new console -o MyApp -f net6.0
2. Enter the project:
3. Edit the Program.cs file
Change the output as you wish, example:
Now run it at runtime:
Note that it will take a while to run, as it was compiled and then executed. If you want to separate tasks: