C# development environment preparation

Development preparation

1. Install visual studio code (vscode)

2. Then install C# Dev Kit in the vscode plug-in library  (the plug-in will automatically install C# extension  and  IntelliCode for C# Dev Kit ). This plug-in requires the installation of .NET SDK

3. After installing the plug-in, restart vscode and you will be prompted that the sdk cannot be found. You can also follow the prompts to download and install the sdk. Of course, you can also download and install it manually.

.Net SDK and C# DEV Kit installation related issues

1. Install the sdk and C# DEV Kit. After restarting vscode, the relevant SDk is not scanned.

First open cmd and execute where dotnet. If the file path is displayed, it means that the environment variables have been configured.

If not, add the dotnet environment variable to Path. There are two default staging paths:

32-bit version: C:\Program Files (x86)\dotnet

64-bit version path: C:\Program Files\dotnet

Note that only one of the paths needs to be added to the environment variable. If both are added, vscode cannot scan the SDK.

2. How to use the windows system itself to run the Csharp program without sdk and C# DEV Kit plug-in?

We can write a cs file with Main such as helloworld.cs

helloworld.cs code is as follows:

using System;
namespace HelloWorldApplication
{
   class HelloWorld
   {
      static void Main(string[] args)
      {
         Console.WriteLine("Hello World");
         Console.ReadKey();
      }
   }
}

Go to the directory where the file is located in the command window and execute csc helloworld.cs to compile and generate helloworld.exe.

Then execute helloworld to run the program

3. What should I do if the csc command cannot be found? If it prompts that the csc command cannot be recognized   , environment variables need to be configured (Window10)

Reference: C# Program Structure | Newbie Tutorial

Find the "Computer" icon on the desktop, right-click, and click "Properties" - "Advanced System Settings" - "Environment Variables" - "System Variables" in the pop-up menu, find the variable Path, and add  a path  ;C:\Windows\Microsoft.NET\Framework\v2.0.50727\ (note that multiple paths are separated by semicolons (;), other versions of Windows can be appended at the end).

Click on the image to see a larger version

Guess you like

Origin blog.csdn.net/weixin_41385146/article/details/131097223