Lesson 2 — The Platform

.NET Overview

C# runs on .NET. Understanding the platform — its components, project types, and CLI — helps you build the right thing with the right tools.

What is .NET?

.NET is a free, open-source, cross-platform development platform. Modern .NET (version 5+) unified the previously fragmented ecosystem: .NET Framework (Windows-only, legacy), .NET Core (cross-platform 2016-2020), and Xamarin (mobile). Today there is one .NET for all platforms.

Core Components

  • CLR — Common Language Runtime. Executes IL code, manages memory (garbage collection), handles exceptions. The .NET equivalent of Java's JVM.
  • BCL — Base Class Library. Standard library: collections, IO, networking, cryptography, text processing — thousands of classes built in.
  • NuGet — the package manager. Like npm for JavaScript. Thousands of open-source packages at nuget.org.
CSHARP — dotnet CLI
dotnet --version

// Create and run a console project:
dotnet new console -n MyApp
cd MyApp
dotnet run

// Add a NuGet package:
dotnet add package Newtonsoft.Json

// Build for release:
dotnet publish -c Release

Project Types

  • console — command-line application. Where you start.
  • webapi — ASP.NET Core REST API. Dominant for backend services.
  • mvc — Web application with views.
  • blazorwasm — C# running in the browser via WebAssembly.
  • maui — Cross-platform mobile and desktop.
  • classlib — Reusable class library (DLL).
  • xunit — Unit testing project.

The .csproj File

CSHARP — Project file
<!-- MyApp.csproj -->
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
  </ItemGroup>
</Project>

Choosing an IDE

  • Visual Studio Community (free, Windows/Mac) — most feature-rich .NET IDE.
  • VS Code + C# Dev Kit (free, cross-platform) — lighter, excellent on Linux.
  • JetBrains Rider (paid, cross-platform) — widely used in SA enterprise.

Practice Task

Your Turn

Install the .NET SDK. Run dotnet --version. Create a console project called Your IT TutorProfile, edit Program.cs to print your name and DateTime.Now.ToString("D"), then run it. Add the Newtonsoft.Json package and confirm it appears in your .csproj.

Common Mistakes

  • Confusing .NET Framework (legacy Windows-only) with modern .NET.
  • Running dotnet run outside the project directory — must be inside the folder with the .csproj.
  • Forgetting dotnet restore after pulling code — restores NuGet packages.
  • Mixing .NET versions — use dotnet --list-sdks to see what is installed.

Professional Tip

The .NET ecosystem moves fast. Microsoft releases a new major version every November with LTS versions every two years. Check the .NET blog to stay current.

Mini Quiz

What does NuGet provide in the .NET ecosystem?