In .NET core, I have already been exposed to it, I have written a website, and it has been successfully deployed on a Linux server, and it has been running in a production environment.
This time, look at Microsoft's official documentation and learn systematically. NET Core! Why study. What about .NET Core? It and . NET Framework?
.NET Core has the following features:
- Cross-platform: Can run on Windows, macOS, and Linux operating systems.
- Align across architectures: Run code with the same behavior on multiple architectures, including x64, x86, and ARM.
- Command line tools: Includes easy-to-use command-line tools for local development and continuous integration scenarios.
- Flexible deployment: Can be included in the scope of an app or installed parallel user or computer. Works with Docker containers.
- Compatibility.NET Core is compatible with the .NET Framework, Xamarin, and Mono via .NET Standard.
- Open sourceThe .NET Core platform is open source and uses MIT and Apache 2 licenses. .NET Core is a .NET Foundation project.
- Powered by Microsoft.NET Core is powered by Microsoft as a .NET Core support.
Official documentation link:The hyperlink login is visible.
1. Install the .NET Core SDK environment
Download Address:The hyperlink login is visible.Depending on the situation, download and install it, omitted.
2. Check the SDK and version of the machine
To view all the SDKs installed on the machine, execute the cmd command as follows:
Review the currently selected version of dotnet
3. Create a new console project
We created a new test1 folder under the C:\project\dotnet directory,The project name is named after the folder name by default。
Go to the test1 folder and execute the following commands in turn:
Starting with the .NET Core 2.0 SDK, there is no need to run dotnet restore because it is implicitly run by all commands that need to be restored, such as dotnet new, dotnet build, and dotnet run.
If you want to execute the compiled program, you can go to the \bin\Debug\netcoreapp2.1 folder of the project and run dotnet test1.dll.
3. Develop IDE tools
We recommend using VS Code as our development tool, and if you want to do it well, you must first sharpen your tools. Download Address:https://code.visualstudio.com/
After opening the project with VS code, the editor automatically installs 3 plugins, as follows:
Installing C# dependencies...
Platform: win32, x86_64
Downloading package 'OmniSharp for Windows (.NET 4.6 / x64)' (31021 KB).................... Done! Installing package 'OmniSharp for Windows (.NET 4.6 / x64)'
Downloading package '.NET Core Debugger (Windows / x64)' (43046 KB).................... Done! Installing package '.NET Core Debugger (Windows / x64)'
Downloading package 'Razor Language Server (Windows / x64)' (46894 KB).................... Done! Installing package 'Razor Language Server (Windows / x64)'
Finished
4. Create a new class
To add a new class, right-click on VSCode Explorer and select New File. This action adds the new file to the folder that opened in VSCode. Name the file Class1.cs. It must be saved with the .cs extension at the end so that it is recognized as a csharp file.
Add the code below to create the first class. Make sure to include the correct namespace so that it can be referenced from the Program.cs file.
Class1 file code:
Call the class in the Main method, and the output is as follows:
(End)
|