Setting Up Your Development Environment
Vaibhav • September 11, 2025
Before we can write our first line of C# code, we need to prepare the tools that will help us do it. In this article, we’ll walk through setting up a modern C# development environment from scratch. You’ll install the necessary software, write your first program, and understand how C# projects are structured behind the scenes.
Installing the .NET SDK
The .NET SDK (Software Development Kit) is the foundation of C# development. It includes the compiler, runtime, and command-line tools needed to build and run C# applications.
To install it:
- Visit dotnet.microsoft.com/Download the .NET SDK (not just the runtime)
- Download and run the installer for your operating system (Windows, macOS, or Linux)
After installation, open a terminal or command prompt and run:
dotnet --version
If you see a version number, the SDK is installed correctly. This command confirms that the .NET CLI (Command Line Interface) is available and ready to use.
The .NET CLI is a powerful tool that lets you create, build, and run C# projects directly from the terminal-no IDE required.
Choosing an Editor: Visual Studio or VS Code
You can write C# code in any text editor, but using a modern IDE (Integrated Development Environment) makes life much easier. Microsoft offers two excellent options:
Visual Studio
This is the full-featured IDE for Windows. It includes a graphical interface, debugger, project templates, and more. Choose the “Community” edition-it’s free for individual developers and small teams.
Visual Studio Code (VS Code)
A lightweight, cross-platform editor that works on Windows, macOS, and Linux. It’s fast, customizable, and supports C# through the C# extension (powered by OmniSharp).
To set up VS Code for C#:
- Install VS Code from code.visualstudio.com
- Search for “C#” and install the official extension by Microsoft
If you're just starting out, VS Code is a great choice. It's simple, fast, and works well with the .NET CLI.
Creating Your First C# Project
Let’s create a simple console application that prints a message to the screen. Open your terminal and run:
dotnet new console -n HelloWorld
This command does three things:
dotnet new console
creates a new console application-n HelloWorld
names the project “HelloWorld”- It generates a folder with starter files
Navigate into the project folder:
cd HelloWorld
Now run the program:
dotnet run
You should see:
Hello, World!
Congratulations! You’ve just written and executed your first C# program.
The dotnet run
command compiles your code and then executes the
resulting program in one step.
Understanding the Project Structure
Let’s take a closer look at what was created inside the HelloWorld
folder:
Program.cs
- This is the main source file. It contains theMain
method, which is the entry point of your program.HelloWorld.csproj
- This is the project file. It defines the project type, target framework, and dependencies.obj/
andbin/
- These folders are created when you build the project. They contain intermediate and compiled files.
Here’s what the default Program.cs
looks like:
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
Let’s break it down:
using System;
brings in the System namespace, which includes theConsole
class.class Program
defines a class namedProgram
. Every C# program must have at least one class.static void Main(string[] args)
is the entry point. It’s where the program starts running.Console.WriteLine(...)
prints text to the screen.
Always start with a clean folder for each new project. This keeps your code organized and avoids conflicts.
Compiling Without Running
Sometimes you want to compile the code without running it. Use:
dotnet build
This creates an executable in the bin/Debug/netX.X/
folder (where X.X
is your .NET
version). You can run it directly:
dotnet bin/Debug/net8.0/HelloWorld.dll
This separation is useful when you want to build once and run multiple times-especially in larger projects.
Working with VS Code
If you’re using VS Code, open the project folder:
code .
VS Code will detect the C# project and prompt you to install required assets. Accept the prompt. You’ll now have:
- Syntax highlighting
- Code completion
- Integrated terminal
- Debugging support
You can run the program using the terminal or by pressing F5
to start debugging.
The first time you run or debug, VS Code creates a .vscode
folder with
configuration files. These help it understand how to build and run your project.
Common Setup Issues
If something doesn’t work, here are a few things to check:
- Make sure the .NET SDK is installed and
dotnet --version
works - Ensure you’re in the correct folder (where the
.csproj
file is) - Restart VS Code after installing the C# extension
- Use the terminal inside VS Code for consistent behavior
If you’re on Linux or macOS, you may need to install additional dependencies. The .NET install page provides platform-specific instructions.
Summary
In this article, you set up your C# development environment and wrote your first program. You learned how to:
- Install the .NET SDK
- Choose between Visual Studio and VS Code
- Create and run a new C# project using the CLI
- Understand the basic folder and file structure of a C# project
- Use VS Code for editing, running, and debugging
With your environment ready, you’re now equipped to start exploring the language itself. In the next article, we’ll take a closer look at your first C# program and explain how it works line by line.