How to Create a Console Application in Visual Studio Code (C#, .NET 10)

Say you run the counter at a Tucson coffee roaster and want a tiny tool: type a customer’s name and subtotal, get the total with 8.25% sales tax.

Quick answer: To create a console application in Visual Studio Code, install the .NET 10 SDK and the C# Dev Kit, run dotnet new console -n ConsoleApp, open the folder with code . and start it with dotnet run.

We built that tax tool on .NET 10 three ways: the CLI, the Dev Kit menu and one file with no .csproj.

What You Need Before You Start: .NET 10 SDK, VS Code and C# Dev Kit

  • .NET 10 SDK (not just the runtime) from dotnet.microsoft.com. .NET 10 is the current LTS release.
  • Visual Studio Code from code.visualstudio.com, for Windows, macOS or Linux.
  • C# Dev Kit: search for it in the Extensions view (Ctrl+Shift+X) and select Install. It brings the C# extension and a Solution Explorer with it.

Install VS Code and the .NET SDK on Windows in One Go

On Windows, the Learn tutorial links a WinGet configuration file that installs all three at once.

Then open a new terminal and confirm the SDK. If you need more than the version number, here’s how to check your .NET version in detail:

dotnet --version
10.0.402

Step 1: Create the Console App with dotnet new console

We keep demos in C:\DotNetDemo. From there, one command creates the project folder, and two more open it in VS Code:

cd C:\DotNetDemo
dotnet new console -n ConsoleApp
cd ConsoleApp
code .

Output:

The template "Console App" was created successfully.

Processing post-creation actions...
Restoring C:\DotNetDemo\ConsoleApp\ConsoleApp.csproj:
  Determining projects to restore...
  Restored C:\DotNetDemo\ConsoleApp\ConsoleApp.csproj (in 151 ms).
Restore succeeded.

Here’s the generated ConsoleApp.csproj, untouched:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

</Project>

net10.0 is the target framework, and ImplicitUsings is why you don’t need using System;. If you’re on .NET 8, upgrading from .NET 8 to .NET 10 is mostly that one line.

Program.cs holds one line of top-level statements, with no Main method and no class:

Console.WriteLine("Hello, World!");

Output:

Hello, World!

Step 2: Open the Console App Folder in VS Code

VS Code works on folders. code . (or File > Open Folder) opens it, and C# Dev Kit loads ConsoleApp.csproj into the Solution Explorer.

VS Code with the ConsoleApp folder open, the template Program.cs in the editor and dotnet run printing Hello, World! in the integrated terminal
The fresh template in VS Code: Program.cs and dotnet run in the terminal

The integrated terminal (Ctrl+`) starts in that folder, so dotnet run just works.

Folder vs Workspace File

A plain folder is all one console app needs. A .code-workspace file only helps when several folders, say an app and a library, share one window.

Or Use the C# Dev Kit .NET: New Project Command

Prefer menus? In the Explorer view, select Create .NET Project, or press Ctrl+Shift+P and run .NET: New Project. Pick Console App, a location and the name ConsoleApp.

Then choose the solution file format (Learn’s tutorial picks .sln) and select Create Project. You get the same files plus a solution file.

Step 3: Read User Input with Console.ReadLine

Now the tax tool. Console.ReadLine() returns the line the user typed, or null at the end of input. We parse the subtotal with decimal.TryParse, the same approach as converting a number with commas to decimal:

using System.Globalization;

var us = CultureInfo.GetCultureInfo("en-US");

Console.Write("Customer name: ");
string name = Console.ReadLine()?.Trim() ?? "guest";

Console.Write("Order subtotal: ");
string? input = Console.ReadLine();

if (!decimal.TryParse(input, NumberStyles.Currency, us, out decimal subtotal))
{
    Console.WriteLine($"'{input}' isn't a dollar amount.");
    return;
}

decimal total = subtotal * 1.0825m;   // 8.25% sales tax
Console.WriteLine($"{name}, your total is {total.ToString("C", us)}");

Save the file first (VS Code doesn’t auto-save before a run). To run it unattended, I piped two answers in from Command Prompt:

(echo Jenna Morales& echo 42.50) | dotnet run

Output:

Customer name: Order subtotal: Jenna Morales, your total is $46.01
C# console app in VS Code reading a customer name and order subtotal with Console.ReadLine and printing the total with 8.25% sales tax
Piped input isn’t echoed, so both prompts share one line

Jenna’s $42.50 order comes to $46.01. An input of $1,250.00 gives $1,353.13, and forty prints 'forty' isn't a dollar amount.

I set en-US culture explicitly so C formats dollars on any PC, and money is a decimal (see C# data types).

Step 4: Build vs Run a C# Console App

dotnet run builds and starts the app. dotnet build only compiles:

VS Code showing ConsoleApp.csproj with net10.0 and dotnet build output with Build succeeded, 0 warnings and 0 errors
dotnet build writes ConsoleApp.dll to bin\Debug\net10.0
Restore complete (0.3s)
  ConsoleApp net10.0 succeeded (0.1s) → bin\Debug\net10.0\ConsoleApp.dll

Build succeeded in 1.0s

Both default to the Debug configuration. Before you ship, test the optimized build with dotnet run -c Release; ours printed the same $46.01. Runtime errors still need code, such as try-catch in C#.

Step 5: Debug the Console App with F5

Set a breakpoint with F9, then press F5. If asked, pick C#, then C#: Launch startup project. The Variables pane shows name and subtotal.

With C# Dev Kit, you don’t need a launch.json. Step with F10 and F11.

Note: by default, the debugged app’s output goes to the Debug Console. To answer ReadLine prompts in a normal terminal, add this to your user settings. A while loop in C# is a nice thing to step through next:

"csharp.debug.console": "integratedTerminal"

Do You Need a .csproj for a C# Console App?

Not always. The .NET 10 SDK runs a single .cs file with no project, one of the headline new features in .NET 10. Learn advises keeping these files outside project folders, so ours lives in C:\DotNetDemo\ConsoleAppScripts:

using System.Globalization;

var us = CultureInfo.GetCultureInfo("en-US");
decimal[] subtotals = [42.50m, 18.75m, 1250.00m];

foreach (decimal subtotal in subtotals)
{
    decimal total = subtotal * 1.0825m;
    Console.WriteLine($"{subtotal.ToString("C", us),10} -> {total.ToString("C", us)}");
}

Output:

    $42.50 -> $46.01
    $18.75 -> $20.30
 $1,250.00 -> $1,353.13
VS Code running the .NET 10 file-based app TaxCheck.cs with dotnet run TaxCheck.cs and no .csproj, printing three subtotals with tax
dotnet run TaxCheck.cs: same tax math, no project file

Packages go in #:package lines at the top, and dotnet project convert TaxCheck.cs turns the file into a project later.

Important: inside a folder with a .csproj, dotnet run file.cs runs the project and passes the file name as an argument.

Console App Cheat Sheet: Project vs File-Based App

This is the table we hand to new team members. If C# itself is new to you, start with what C# is and what it builds:

dotnet new console projectFile-based app
Createdotnet new console -n ConsoleAppAny .cs file
Files.csproj + Program.csOne .cs file
Rundotnet run or F5dotnet run app.cs
Build outputbin\Debug\net10.0A temp folder
Use it forApps you’ll grow, test and shipScripts, utilities, quick tests

Common Mistakes to Avoid When You Create a Console App

I hit each of these on purpose on our Windows PC.

‘dotnet’ Is Not Recognized

The SDK isn’t installed, or its folder isn’t on PATH. Command Prompt says:

'dotnet' is not recognized as an internal or external command,
operable program or batch file.

Install the SDK, then close and reopen VS Code so the terminal picks up the new PATH.

A Compatible .NET SDK Was Not Found

A global.json asks for an SDK you don’t have. We pinned 11.0.100 and got:

{
  "sdk": {
    "version": "11.0.100"
  }
}
A compatible .NET SDK was not found.
Requested SDK version: 11.0.100
global.json file: C:\DotNetDemo\SdkPinDemo\global.json

Install that SDK or change the version in global.json.

Couldn’t Find a Project to Run

You ran dotnet run one folder too high:

Couldn't find a project to run. Ensure a project exists in C:\DotNetDemo, or pass the path to the project using --project.

cd ConsoleApp first, or pass --project ConsoleApp. The Learn C# tutorial path uses this same layout.

Next Steps

Your console app runs, reads input and debugs. Next, add logic: loop over orders with a for loop, then split the code into small methods.

Once the tax tool runs, our team usually points beginners to these:

Frequently Asked Questions

Can I create a C# console app in VS Code without C# Dev Kit?

Yes. The CLI commands only need the .NET SDK; the extension adds IntelliSense and F5 debugging.

Which .NET version should I target for a new console app?

.NET 10. It’s the current long-term support release, and dotnet new console on the .NET 10 SDK targets net10.0 by default.

Why doesn’t Console.ReadLine wait for input when I debug?

The debugged app writes to the Debug Console by default. Type your answer there, or set csharp.debug.console to integratedTerminal.

How do I run a single C# file without a project?

With the .NET 10 SDK, run dotnet run app.cs or dotnet app.cs. See File-based apps on Microsoft Learn.

Is VS Code or Visual Studio better for console apps?

Both work. VS Code is lighter and cross-platform; Visual Studio has richer Windows tooling.