In this tutorial, you will learn how to run a C# console program in Visual Studio Code.
Step-by-Step Instructions#
Option 1. Using the Play Button#
- Open Visual Studio Code and open the folder containing your project.
- Open the main program file, usually
Program.cs. - Click the play button at the top-right corner.
- VS Code will build and run the program, and the Terminal panel will open automatically, showing the output.
Make sure you save your changes (File -> Save or
Ctrl + S) to run the latest version of your program.
Option 2. Using the Terminal / .NET CLI#
- Open the Terminal:
- Go to View -> Terminal.
- Or press `Ctrl + `` (backtick).
- Verify that the terminal is in your project folder (the folder containing the
*.csprojfile):- If you are in the parent folder, use
cd folder_nameto navigate into the project folder. - If you are in a subfolder, use
cd ..to move one folder up.
- If you are in the parent folder, use
- Run the project with the command:
dotnet run- VS Code will build and run the program, and the output will appear below the
dotnet runcommand.
Make sure you save your changes (File -> Save or
Ctrl + S) to run the latest version of your program.