Initial Setup
Get C# running on your machine. This tutorial guides you through installing the .NET SDK, setting up your development environment, and verifying everything works. By the end, you’ll have a working C# development environment ready for learning.
What You’ll Achieve
- Install .NET 8 SDK (latest LTS version)
- Configure your development environment (VS Code or Visual Studio)
- Verify installation with a test program
- Understand .NET SDK structure and tooling
- Set up your first C# project
Time to complete: 15-30 minutes (varies by internet speed and platform)
Coverage: 0-5% (environment setup foundation)
Prerequisites
- Operating System: Windows 10/11, macOS 10.15+, or Linux (Ubuntu 20.04+, Fedora 36+, Debian 11+)
- Disk Space: 500 MB for .NET SDK, 2 GB for Visual Studio (optional), 200 MB for VS Code
- Internet Connection: Required for downloading SDK and extensions
No prior programming knowledge required - this tutorial starts from zero.
Step 1: Install .NET SDK
Windows
Option A: Installer (Recommended)
- Visit https://dotnet.microsoft.com/download
- Click “Download .NET 8.0 SDK” (LTS version)
- Run the downloaded installer (.exe file)
- Follow installation wizard (default options work well)
- Restart terminal/PowerShell after installation
Option B: Winget (Command Line)
winget install Microsoft.DotNet.SDK.8Verification:
dotnet --version
# => Should show 8.0.xxxmacOS
Option A: Installer
- Visit https://dotnet.microsoft.com/download
- Download .NET 8.0 SDK for macOS
- Open the .pkg file and follow installation wizard
- Restart terminal after installation
Option B: Homebrew (Recommended)
brew install --cask dotnet-sdkVerification:
dotnet --version
# => Should show 8.0.xxxLinux (Ubuntu/Debian)
# Add Microsoft package repository
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
# Install .NET SDK
sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0
# Verify installation
dotnet --version
# => Should show 8.0.xxxLinux (Fedora)
# Add Microsoft package repository
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo wget -O /etc/yum.repos.d/microsoft-prod.repo https://packages.microsoft.com/config/fedora/37/prod.repo
# Install .NET SDK
sudo dnf install dotnet-sdk-8.0
# Verify installation
dotnet --version
# => Should show 8.0.xxxStep 2: Choose Your Editor
Option A: Visual Studio Code (Recommended for Learning)
Why VS Code?
- Lightweight and fast
- Cross-platform (Windows, macOS, Linux)
- Excellent C# extension with IntelliSense
- Free and open source
- Great for learning before committing to full IDE
Installation:
- Download from https://code.visualstudio.com/
- Install C# Dev Kit extension:
- Open VS Code
- Click Extensions icon (or Ctrl+Shift+X / Cmd+Shift+X)
- Search for “C# Dev Kit”
- Click Install (installs C# extension + C# Dev Kit)
Verification:
- Open VS Code
- Create new file:
test.cs - Type:
Console.WriteLine("Hello"); - IntelliSense should suggest
WriteLine(autocomplete working)
Option B: Visual Studio (Full IDE)
Why Visual Studio?
- Full-featured IDE with advanced debugging
- Best for enterprise development
- Built-in project templates and designers
- Windows and macOS only (no Linux)
Installation:
- Download Visual Studio 2022 Community (free) from https://visualstudio.microsoft.com/
- During installation, select “.NET desktop development” workload
- Optional: Also select “ASP.NET and web development” for web apps
Option C: JetBrains Rider
Why Rider?
- Professional IDE with excellent refactoring
- Cross-platform
- Powerful code analysis
- Commercial (paid, 30-day trial available)
Installation: Download from https://www.jetbrains.com/rider/
For this tutorial series, we’ll use VS Code in examples for maximum accessibility.
Step 3: Verify Installation
Let’s confirm everything works by creating and running a simple program:
Create Test Project
# Create new directory
mkdir test-csharp
cd test-csharp
# Create new console application
dotnet new console
# You should see:
# => The template "Console App" was created successfully.
# => Processing post-creation actions...
# => Running 'dotnet restore'...
# => Restore succeeded.Inspect Generated Files
ls
# => Program.cs # Your main code file
# => test-csharp.csproj # Project file (build configuration)
# => obj/ # Build artifacts (ignore)Examine Program.cs
cat Program.csYou should see:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");Run Your First Program
dotnet run
# => Hello, World!Success! If you see “Hello, World!”, your C# environment is working correctly.
Step 4: Understanding .NET SDK Structure
Key Commands
# Version information
dotnet --version # SDK version
dotnet --info # Detailed environment info
# Project commands
dotnet new # List available templates
dotnet new console # Create console app
dotnet new webapi # Create Web API
dotnet new classlib # Create class library
# Build and run
dotnet build # Compile project
dotnet run # Build and run
dotnet clean # Remove build outputs
# Package management
dotnet add package <name> # Add NuGet package
dotnet restore # Restore dependenciesProject File (.csproj)
The .csproj file contains build configuration:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>Key settings:
OutputType: Exe (executable) vs LibraryTargetFramework: net8.0 (.NET 8)ImplicitUsings: Auto-import common namespacesNullable: Enable nullable reference types
Step 5: Configure VS Code for C# Development
If using VS Code, set up these productivity features:
Recommended Settings
Create .vscode/settings.json in your project:
{
"omnisharp.enableRoslynAnalyzers": true,
"omnisharp.enableEditorConfigSupport": true,
"editor.formatOnSave": true,
"csharp.semanticHighlighting.enabled": true
}Recommended Extensions
- C# Dev Kit (Microsoft) - Core C# support
- C# (Microsoft) - Language support
- .NET Install Tool (Microsoft) - Manage SDK versions
- NuGet Package Manager (jmrog) - Browse and install packages
Keyboard Shortcuts
F5- Start debuggingCtrl+F5- Run without debuggingF12- Go to definitionShift+F12- Find all referencesCtrl+.- Quick actions and refactorings
Troubleshooting
“dotnet: command not found”
Solution: SDK not in PATH. Restart terminal or add manually:
- Windows: Already in PATH after installer
- macOS/Linux: Add to
~/.bashrcor~/.zshrc:
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT“It was not possible to find any compatible framework version”
Solution: Wrong .NET version or missing runtime.
# Check installed SDKs
dotnet --list-sdks
# Check installed runtimes
dotnet --list-runtimes
# If missing, reinstall .NET 8 SDKIntelliSense not working in VS Code
Solution:
- Ensure C# Dev Kit extension installed
- Open folder containing
.csprojfile (not individual .cs file) - Wait for “Restore complete” notification in bottom status bar
- If still broken: Reload VS Code (Ctrl+Shift+P → “Reload Window”)
“The current .NET SDK does not support targeting .NET 8.0”
Solution: Update to .NET 8 SDK:
dotnet --version
# If < 8.0, download and install from https://dotnet.microsoft.com/downloadWhat’s Next?
With your environment set up, you’re ready to start learning C#:
- Quick Start - Write your first meaningful C# program with basic syntax touchpoints
- By Example: Beginner - Learn through 30 annotated code examples
Key Takeaways
- .NET SDK includes compiler, runtime, and tools - Everything needed for C# development
- dotnet CLI is your primary tool - Build, run, test, and manage projects from command line
- Cross-platform from day one - Same code runs on Windows, macOS, and Linux
- VS Code provides excellent C# support - Free, lightweight, and powerful enough for professional work
Why It Matters
.NET 8 represents Microsoft’s unified platform vision - one SDK for desktop, web, mobile, cloud, and IoT development. Installing the SDK gives you access to ASP.NET Core for web development, Entity Framework Core for databases, MAUI for cross-platform mobile apps, and thousands of NuGet packages for every domain. The cross-platform nature means you can develop on macOS, deploy to Linux servers, and target Windows desktops with a single codebase - a capability that was impossible with legacy .NET Framework.