Visual Studio or Visual Studio Code?
Visual Studio is Microsoft’s full Windows IDE with project templates, build tools and an integrated debugger. Visual Studio Code is a lighter, separate editor available on Windows, macOS and Linux; C# tooling is added through its supported extensions and an installed .NET SDK. Choose either for a console app, but do not follow Visual Studio menu instructions in VS Code.
This guide uses current Visual Studio for Windows. Visual Studio for Mac was retired in August 2024 and is not a supported installation path. On macOS or Linux, use the .NET SDK with a supported editor such as VS Code and the terminal guides linked below.
Install Visual Studio and its C# workload
Download the current supported Visual Studio for Windows from Microsoft and check its licence terms for your intended use. In the Visual Studio Installer, select the .NET desktop development workload for a console or Windows desktop project. This workload provides the relevant .NET tooling and templates. ASP.NET and web development is a separate workload for web apps; you do not need it for this console walkthrough.
The console example here targets .NET 10. Microsoft’s compatibility table lists Visual Studio 2026 (18.0 or newer) for .NET 10. If you have Visual Studio 2022, check the target-framework compatibility table before selecting a framework: an older IDE might not support the newest SDK target. Finish installation and allow the installer to update its components before opening the IDE.
- Download a supported Windows edition from Microsoft.
- Select .NET desktop development in the installer and finish setup.
- Check the installed Visual Studio version and available .NET target frameworks.
Create and open a console project
Start Visual Studio, choose Create a new project, search for Console App and select the C# template. Set a project name such as FirstCSharp, choose a writable location, and select .NET 10 if your Visual Studio installation supports it. Visual Studio then opens the project. The project template and target picker may vary slightly with installed workloads and SDKs.
In Solution Explorer, Program.cs is your editable C# source. The .csproj file describes the project and target framework. Visual Studio also manages a solution file (.sln or .slnx, depending on version) that groups projects. Build output appears in bin and intermediate files in obj; do not edit those generated folders. If the Console App template is missing, check the .NET desktop development workload in Visual Studio Installer.
- Choose Create a new project, then Console App for C#.
- Name the project and select a supported target framework.
- Open Program.cs from Solution Explorer.
Write, build and run the app
Replace Program.cs with the example below and save it. Use Debug > Start Without Debugging (Ctrl+F5) to build and run without attaching the debugger, or Start Debugging (F5) to run under it. The console displays Hello, Codectionary!. The top-level statement is a complete first program in the modern template; the SDK supplies the entry point.
If Visual Studio reports a compiler error, open View > Error List or the Build output, read the error code and message, and double-click the entry to reach the source line. Fix the first relevant error, save and build again. For example, removing the closing quotation mark makes the string invalid, so the program cannot run until it is corrected.
Program.cs
Console.WriteLine("Hello, Codectionary!");Pause at a breakpoint and inspect a variable
Replace Program.cs with the small example below. Click the left gutter beside the second line or place the caret there and press F9 to set a breakpoint. Press F5 to start debugging. Visual Studio pauses before executing that line. Hover over name or open Debug > Windows > Locals to inspect its current value. F10 steps over the highlighted line; F5 continues execution. Remove the breakpoint with F9 when finished.
A breakpoint pauses a running program; it does not fix a compiler error. If the build fails, use Error List first. If the debugger never pauses, confirm that the breakpoint is on an executable line and that you started with F5 rather than Ctrl+F5. Do not put breakpoints in a different project’s Program.cs by mistake.
Program.cs — value to inspect
string name = "Sam";
Console.WriteLine($"Hello, {name}!");Continue learning
Try changing name, set a breakpoint again, and predict what Locals and the console will show. The same C# language also works with web, desktop, game and service frameworks, but their templates and debugging steps differ. Learn ordinary console syntax first, then choose a framework for the application you want to build.
Syntax
Console.WriteLine("Hello, Codectionary!");Examples
Inspect a greeting while debugging
Set a breakpoint on the WriteLine statement, then inspect name in Locals.
string name = "Sam";
Console.WriteLine($"Hello, {name}!");- The first line stores Sam as text in name; the second formats that value into a greeting and writes Hello, Sam! to the console.
- When the debugger pauses before WriteLine, name already has the value Sam. View it by hovering or opening the Locals window.
- F10 executes the highlighted statement; F5 continues. This helps you compare the actual state of a program with the output you expected.
Best practices
- Use a current, supported Windows version of Visual Studio and select a target framework it supports.
- Install .NET desktop development for a console project.
- Use Ctrl+F5 for ordinary running and F5 for debugger sessions.
- Read Error List for build failures before trying breakpoints.
Runtime & versions
.NET runtime. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
C# language reference