[Answer] I Already Have VS C++ — How Do I Set Up C#?
![[Answer] I Already Have VS C++ — How Do I Set Up C#?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2Fvscc-43685212.png&w=3840&q=75)
[Answer] I Already Have VS C++ — How Do I Set Up C#?
[Answer] I Already Have VS C++ — How Do I Set Up C#?
Prerequisites
- Install the C# extension for Visual Studio Code. You can also install the official C# Dev Kit.
- Install the .NET 7 SDK or another version.
Create an Application
Start VS Code. You can create a new project folder and open it in VS Code, then open the VS Code terminal in that directory and run the following command to create a console application.
dotnet new console --framework net7.0
You can also use the following command to create a project named MyCSharpApp (inside the MyCSharpApp project directory):
dotnet new console -n MyCSharpApp --framework net7.0
Run dotnet run and you will see the command-line output Hello World.
By default, the project template generates a main program with just one top-level statement:
Console.WriteLine("Hello, world");
You can modify it as needed to use a namespace-based style instead:
namespace vscodesharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, world");
}
}
}
Add References
If you want to add a library reference to the project, you can use a command such as dotnet add package System.IO.Ports, and then import it with using System.IO.Ports;.
![[Thought] Many viruses you’ve probably never heard of also contain DNA, such as iridoviruses](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2Fdna-39161584.png&w=3840&q=75)
![[Answer] What did you do on the night you checked your Gaokao score?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2F-e4a8ec38.png&w=3840&q=75)
![[Answer] How Can You Score 130+ on the Gaokao Math Exam?](/_next/image?url=https%3A%2F%2Flxunzzzdnokdqhipbmdf.supabase.co%2Fstorage%2Fv1%2Fobject%2Fpublic%2Fmedia%2Fcovers%2F130-157dba52.png&w=3840&q=75)