📝 Lesson 1.2: Setting Up Your Environment
Let's get the tools onto your computer. By the end of this lesson you'll have everything installed and verified — ready to write and run real C# programs in the next lesson.
🎯 Learning Objectives
By the end of this lesson, you will be able to:
- Explain the difference between the .NET SDK and a code editor
- Install the .NET SDK on Windows, macOS, or Linux and verify it works
- Choose and set up an editor — VS Code (any OS) or Visual Studio (Windows)
- Use a terminal well enough to run a couple of basic commands
Estimated Time: 45 minutes
Project: A fully working C# development environment, confirmed with a version check.
In This Lesson
What You Need to Install
To write and run C#, you need exactly two things. It's worth understanding the difference, because beginners often confuse them:
| Tool | What it does | Analogy |
|---|---|---|
| The .NET SDK (required) | The engine and toolkit that actually builds and runs C# code. Without it, nothing runs. | The kitchen, oven, and ingredients |
| A code editor (required) | The program where you write and edit your code comfortably, with color-coding and helpful hints. | Your recipe notebook and workspace |
💡 The key point
The SDK does the real work of building and running. The editor is just a comfortable place to write. You could technically write C# in a plain text editor like Notepad — but a real editor makes it much easier by highlighting your code and catching mistakes as you type.
(where you write)"] --> B["Program.cs
(your code file)"] B --> C[".NET SDK
(builds & runs)"] C --> D["Program runs"] style A fill:#eff6ff,stroke:#3b82f6,stroke-width:2px style D fill:#e8f5e9,stroke:#4CAF50,stroke-width:2px
Choosing Your Editor
You only need one editor. Here are the two most popular choices for C#. Both are free.
| Visual Studio Code (VS Code) | Visual Studio | |
|---|---|---|
| Runs on | Windows, macOS, Linux | Windows (also a separate "for Mac" being retired) |
| Size / weight | Light and fast | Large, full-featured |
| Style | A code editor you extend with add-ons | An all-in-one IDE with menus and buttons for everything |
| Best if you… | Are on Mac/Linux, or like something lightweight | Are on Windows and prefer a guided, button-driven experience |
✅ Which should you pick?
If you're unsure, choose VS Code — it works on every operating system, so it matches this course's examples exactly, and it's what most of our command-line steps assume. If you're on Windows and like a more visual, all-in-one tool, Visual Studio is a great choice too. Follow whichever setup section applies to your pick (Step 3a or Step 3b).
Step 1: Install the .NET SDK
This step is the same no matter which editor you chose. (If you pick Visual Studio in Step 3b, its installer can include the SDK for you — but installing it directly first never hurts and guarantees the dotnet command works everywhere.)
- Go to the official download page: https://dotnet.microsoft.com/download
- Download the .NET SDK (not the "Runtime" — the SDK includes the runtime plus the build tools you need). Choose the latest LTS version if offered ("LTS" = Long-Term Support = stable and supported for years).
- Run the installer and accept the defaults.
⚠️ SDK vs. Runtime
The download page offers both an SDK and a Runtime. The Runtime only runs finished programs; the SDK both builds and runs them. As a developer, you need the SDK. If you only see a Runtime, look for the SDK download.
Platform notes
🪟 Windows
Download the x64 installer (or Arm64 if you have an Arm-based PC), run it, and click through. That's it.
🍎 macOS
Download the installer for your chip — Arm64 for Apple Silicon (M1/M2/M3/M4) or x64 for older Intel Macs. Not sure? Click the Apple menu → About This Mac and look at the "Chip" line.
🐧 Linux
The easiest path is usually your distribution's package manager. Microsoft's page links per-distro instructions. For example, on Ubuntu the SDK is available via apt:
sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0
(Use whichever LTS version number the docs currently recommend.)
Step 2: Verify the SDK
Let's confirm the SDK installed correctly. You'll do this in a terminal — a text window where you type commands. Don't worry, we only need one command.
💡 How to open a terminal
- Windows: Press the Start key, type "Terminal" or "PowerShell", and open it.
- macOS: Press Cmd+Space, type "Terminal", and press Enter.
- Linux: Open your Terminal app (often Ctrl+Alt+T).
In the terminal, type this and press Enter:
dotnet --version
You should see a version number printed back, something like:
Output (your number may differ):
8.0.404
Seeing a version number means success — the SDK is installed and reachable. You can also list what's installed with:
dotnet --info
⚠️ "command not found" or "not recognized"?
If the terminal says dotnet isn't recognized, try these in order:
- Close and reopen the terminal — a fresh terminal picks up the newly installed command.
- Restart your computer — this reliably refreshes the system's list of available commands.
- Re-run the installer and confirm it completed without errors.
Step 3a: Set Up VS Code
Follow this section if you chose VS Code. If you chose Visual Studio, skip to Step 3b.
- Download VS Code from https://code.visualstudio.com/ and install it (accept the defaults).
- Open VS Code and click the Extensions icon in the left sidebar (it looks like four squares), or press Ctrl+Shift+X (Cmd+Shift+X on Mac).
- In the search box, type "C# Dev Kit" and install the extension published by Microsoft. This automatically installs the base "C#" extension too, giving you color-coding, error underlining, and autocomplete.
✅ That's all you need
With the SDK installed and the C# Dev Kit extension added, VS Code is ready. In the next lesson you'll open a folder and VS Code will recognize your C# project automatically.
💡 Tip: the built-in terminal
VS Code has a terminal built right in — open it with View → Terminal (or Ctrl+`, the backtick key). You'll run your dotnet commands there without leaving the editor.
Step 3b: Set Up Visual Studio
Follow this section if you chose Visual Studio (Windows). If you chose VS Code, you're done — skip ahead.
- Download Visual Studio Community (free) from https://visualstudio.microsoft.com/. "Community" is the free edition — plenty for this course and beyond.
- Run the installer. It will show a screen of "Workloads." Check the box for ".NET desktop development" — this bundles the C# tools and the .NET SDK together.
- Click Install and wait (it's a large download). When it finishes, launch Visual Studio.
✅ SDK included
Because the ".NET desktop development" workload installs the SDK for you, Visual Studio users may be able to skip a separate SDK download. Running dotnet --version in a terminal (Step 2) is still a good way to confirm everything is wired up.
💡 What's different from VS Code?
In Visual Studio you'll often use menus and buttons (like the green ▶ "Run" button) instead of typing terminal commands. Where this course shows a dotnet command, we'll also mention the equivalent Visual Studio action so you can follow along either way.
A Few Terminal Basics
Even if you use Visual Studio's buttons, knowing a handful of terminal commands is a genuine superpower for a developer. Here are the essentials — the same ideas apply on every operating system, with minor differences:
| Goal | Windows (PowerShell) | macOS / Linux |
|---|---|---|
| Show current folder | pwd |
pwd |
| List files in this folder | dir or ls |
ls |
| Move into a folder named "myapp" | cd myapp |
cd myapp |
| Go up one folder | cd .. |
cd .. |
| Make a new folder | mkdir myapp |
mkdir myapp |
💡 The mental model: A terminal is always "sitting" inside one folder at a time.cd("change directory") moves you around;ls/dirshows what's there. In the next lesson you'llcdinto a project folder and run it.
✅ Pro Tip: Tab completion
Start typing a folder or file name and press Tab — the terminal will auto-complete it for you. This saves typing and avoids spelling mistakes.
Exercise & Quiz
🏋️ Exercise: Confirm Your Setup
Objective: Prove that your environment is ready before moving on.
Instructions:
- Open a terminal.
- Run
dotnet --versionand confirm you see a version number. - Create a practice folder and move into it:
mkdir csharp-course
cd csharp-course
pwd
The final pwd should show you're now inside the csharp-course folder. You'll use this folder in the next lesson.
💡 Hint
If dotnet --version fails, revisit Step 2's troubleshooting box — the most common fix is simply closing and reopening the terminal, or restarting your computer after installing.
✅ What success looks like
Running the commands should print something like this (your version number and path will differ):
8.0.404
/Users/you/csharp-course
If you see a version number and your new folder path, your environment is ready. 🎉
🎯 Quick Quiz
Question 1: Which tool actually builds and runs your C# code?
Question 2: On the download page, should you install the .NET SDK or the Runtime?
Question 3: What does the terminal command cd do?
Summary
🎉 Key Takeaways
- You need two things: the .NET SDK (builds and runs code) and a code editor (where you write it).
- Install the SDK, not just the Runtime — the SDK includes the build tools developers need.
- Verify the install with
dotnet --version; a version number means success. - Pick one editor: VS Code + C# Dev Kit (any OS) or Visual Studio Community (Windows).
- A few terminal commands —
pwd,ls/dir,cd,mkdir— are all you need to get around.
📚 Additional Resources
🚀 What's Next?
Your workshop is set up and your tools are verified. In Lesson 1.3: Your First C# Program, you'll create a real project with the dotnet command, look at every line of the starter code, and run your very first program.
🎉 Setup complete!
The hardest part of setup is behind you. From here on, it's all about writing code.