C# is a statically-typed, object-oriented language created by Microsoft and first released in 2002. It runs on the .NET platform — a runtime and class library that abstracts the operating system and provides a managed execution environment. Understanding the relationship between C# (the language you write) and .NET (the platform that runs it) is the foundation for everything in this series. The ASP.NET Core Web API stack you will build in Parts 3 and 4, the Angular frontend in Part 5, and the SQL Server integration in Part 6 all run on this foundation.
The .NET Platform
C# Source Code (.cs files)
↓ C# Compiler (Roslyn)
Intermediate Language (IL / MSIL) inside .dll or .exe
↓ CLR: JIT Compiler (at runtime, per method)
Native Machine Code (x64, ARM64, etc.)
↓
Execution on any supported OS
Key components:
CLR — Common Language Runtime (memory management, GC, JIT, exceptions)
BCL — Base Class Library (System.*, Collections, IO, Net, Threading, ...)
SDK — dotnet CLI, MSBuild, project templates, publish tools
NuGet — package manager (like npm for JavaScript, pip for Python)
.NET versions — always use .NET 8 (current LTS):
.NET Framework 1.0–4.8 — Windows only, legacy — do NOT use for new projects
.NET Core 1.0–3.1 — Cross-platform (renamed to just .NET from v5)
.NET 5 / 6 / 7 / 8 / 9 — Unified cross-platform runtime (current)
dotnet --version — it should print 8.x.x. The recommended IDE is Visual Studio 2022 Community (free) on Windows, which has first-class C#, ASP.NET Core, EF Core, and SQL Server tooling. VS Code with the C# Dev Kit extension works cross-platform and is suitable for all parts of this series except some Windows-specific SQL Server tools.net8.0 in the .csproj file. When searching for documentation, check that results are for “ASP.NET Core” not the legacy “ASP.NET Web API 2” (Framework only). The APIs look similar but are different — Framework code does not run on .NET 8.Your First C# Program
# Create a new console application
dotnet new console -n HelloWorld
cd HelloWorld
# Project structure:
# HelloWorld/
# ├── HelloWorld.csproj ← MSBuild project file (like package.json)
# ├── Program.cs ← your code (top-level statements)
# ├── obj/ ← intermediate build files (git-ignore this)
# └── bin/ ← compiled output (git-ignore this)
// Program.cs — top-level statements (.NET 6+)
// No class declaration or static void Main() needed
Console.WriteLine("Hello, World!");
Console.WriteLine($".NET version: {Environment.Version}");
// The compiler automatically generates this behind the scenes:
// namespace HelloWorld;
// internal class Program
// {
// static void Main(string[] args)
// {
// Console.WriteLine("Hello, World!");
// Console.WriteLine($".NET version: {Environment.Version}");
// }
// }
// You never write this boilerplate by hand for entry-point files.
dotnet run
# Hello, World!
# .NET version: 8.0.x
The .csproj Project File
<!-- HelloWorld.csproj — MSBuild XML project definition -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType> <!-- produces a console executable -->
<TargetFramework>net8.0</TargetFramework> <!-- target .NET 8 LTS -->
<Nullable>enable</Nullable> <!-- nullable reference type warnings -->
<ImplicitUsings>enable</ImplicitUsings> <!-- auto-imports System, Linq, etc. -->
</PropertyGroup>
</Project>
<!-- An ASP.NET Core Web API project uses Microsoft.NET.Sdk.Web instead -->
<!-- and does not need the OutputType element -->
Essential dotnet CLI Commands
| Command | Purpose |
|---|---|
dotnet new console -n MyApp |
Create console project |
dotnet new webapi -n MyApi |
Create Web API project |
dotnet run |
Build and run the project |
dotnet build |
Compile without running |
dotnet test |
Run all tests in the solution |
dotnet add package Newtonsoft.Json |
Add a NuGet package |
dotnet publish -c Release |
Build optimised deployment output |
dotnet --info |
Show installed SDKs and runtimes |
Common Mistakes
Mistake 1 — Targeting .NET Framework instead of .NET 8
❌ Wrong — legacy target that is Windows-only:
<TargetFramework>net472</TargetFramework> <!-- .NET Framework 4.7.2 — legacy! -->
✅ Correct:
<TargetFramework>net8.0</TargetFramework> <!-- .NET 8 LTS — modern, cross-platform -->
Mistake 2 — Committing obj/ and bin/ folders to git
dotnet new creates a .gitignore automatically that excludes bin/ and obj/. Always use it — these folders contain compiled binaries regenerated by dotnet build and should never be in source control.