**For other systems, please see: **https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install
To start building. net application, just download and install. net SDK (software development kit).
Before installing .net, you need to register the Microsoft key, register the product repository, and install the required dependencies. This only needs to be performed once on each machine.
Open a terminal and run the following command:
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
Update the products available for installation, and then install the .net SDK.
In your terminal, execute the following command:
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2
If you perform an in-place upgrade later, you may receive an error message similar to the package dotnet-sdk-2.2 cannot be located when trying to install/update .net.
Please refer to the Ubuntu 19.04 installation instructions to learn how to fix this problem.
After the installation is complete, open a new terminal and run the following command:
dotnet
If you run this command and print out the information on how to use dotnet, it will be fine.
If the "dotnet" you receive is not recognized as an internal or external command error, make sure to open a new command prompt.
In your terminal, execute the following command:
dotnet newconsole-o myApp
cd myApp
The dotnet command creates a new console type application for you. The -o parameter creates a directory called myApp, stores the application in it, and fills it with the required files. The cd myApp command puts you in the newly created app directory.
The main file in the myApp folder is Program.cs. By default, it already contains the code needed to write "Hello World!" to the console.
using System;
namespace myApp
{ classProgram{staticvoidMain(string[] args){
Console.WriteLine("Hello World!");}}}
In your terminal, execute the following command:
dotnet run
Congratulations, you have built and run your first .NET application!
Open Program.cs in any text editor (such as Notepad) and print "Hello World!", for example:
Console.WriteLine("The current time is "+ DateTime.Now);
Console.WriteLine("Hello World!");
Save the Program.cs file, and then run the code again.
dotnet run
Congratulations, you have built and run your first .NET application!
If you want to continue learning in general. net skills, please try our introduction to the c# tutorial:
https://docs.microsoft.com/dotnet/csharp/tutorials/intro-to-csharp/numbers-in-csharp-local
Recommended Posts