I’ll be honest with you: the first little while that you are learning to program can be a bit tedious and boring. The simple programs that we’ll be creating at first will be very dull compared to the stuff you’ll be making afterward. But it is an important step. You need to learn to walk before you can learn to run.

Introduction

C# was developed by Microsoft in the early 2000s as a key part of the .NET Framework. Internal development of .NET began in the late 1990s, It was crafted as a modern, object-oriented language designed to rival Java. C# took the best elements from C++ and Java, integrating their strengths while overcoming some of their drawbacks. With a focus on simplicity, performance, and developer productivity, C# quickly became a go-to language for building a wide range of applications, from desktop software to web services and games. Initially, it only supported Windows, as the .NET Framework was designed specifically for Windows-based applications. but the modern version simply called .NET works everywhere cross-platform ( Mac, Linux, Android, iOS)

c# vs .net framework

  • C# is a programming language
  • .Net framework is the platform that enables your code to run

“Think of C# as the “recipe” and .NET Framework as the “kitchen” where you prepare the dish”

.NET implementations

Just as javascript uses different implementations like Nodejs, Bun, Deno to run on a server, C# uses implementations like .net mono etc.

.NET Implementations refer to the different versions and adaptations of the .NET ecosystem designed to run on various operating systems and platforms. These implementations allow developers to create applications that can run on different devices and environments. Each implementation serves a specific purpose, addressing the needs of different application types, such as desktop, web, mobile, or cloud applications.

  • .NET Framework: The original implementation of .NET, developed by Microsoft, primarily for Windows-based applications. It provides a comprehensive set of libraries and tools for building Windows desktop applications and web applications through ASP.NET.

  • .NET Core: A cross-platform, open-source implementation of .NET designed to run on Windows, macOS, and Linux. It was built to enable developers to create applications that can run on multiple platforms without modification, focusing on performance and scalability.

  • .NET: The unified version of .NET, starting from .NET 5, which combines the best features of .NET Framework and .NET Core into one platform. It is cross-platform and open-source, providing support for a wide variety of applications, including web, desktop, mobile, and cloud-based solutions.

  • Mono: An open-source implementation of .NET, Mono provides the runtime environment for executing C# code. designed to bring .NET applications to different platforms such as mobile devices (including iOS and Android) and gaming consoles. It is widely used with Unity for game development and for cross-platform mobile applications.

Mono was initially developed by Xamarin, a company that later became part of Microsoft in 2016. Xamarin’s acquisition by Microsoft allowed Mono to become a core component of their cross-platform mobile development framework, Xamarin, which enables developers to create native applications for iOS, Android, and other platforms using C#.

Timeline of .NET Framework, .NET Core, and .NET Versions

VersionPlatformKey Features and Changes
.NET FrameworkWindows-onlyFirst released in 2002.
1.0.NET FrameworkIntroduced the first implementation of the .NET Framework.
2.0.NET FrameworkIntroduced generics, ASP.NET 2.0, and Windows Forms.
3.5.NET FrameworkIntroduced LINQ, ASP.NET AJAX, and new WCF features.
4.0.NET FrameworkIntroduced parallel programming, MEF (Managed Extensibility Framework), and new security models.
4.5.NET FrameworkAdded async/await keywords, enhanced Windows communication.
4.6.NET FrameworkIntroduced improvements in JIT compiler, better performance, and enhanced cryptography features.
.NET CoreCross-platformReleased in 2016, it is cross-platform (Windows, macOS, Linux).
1.0.NET CoreFirst release of .NET Core, focusing on cross-platform and modularity.
2.0.NET CoreAdded support for more APIs from the .NET Framework, improved performance, introduced the .NET Standard for API consistency.
3.0.NET CoreAdded support for Windows Desktop applications (WPF and Windows Forms), enhanced ASP.NET Core, and Blazor for web applications.
3.1.NET Core (LTS)Long-Term Support release; improved performance, cross-platform improvements, and enhanced APIs.
.NET 5Cross-platformMerged, technically “Replaced” both. Microsoft didn’t actually put the old .NET Framework code into .NET 5 instead, they took .NET Core made it better, and told everyone: “Stop using the old one; .NET is the only one now”
.NET 6Cross-platformLong-Term Support release. Improvements to performance, cloud-native development, cross-platform tools, and enhancements in C# language features. Introduced MAUI for cross-platform UI.
.NET 7Cross-platformFocused on further improvements in performance, cloud-native support, and new features for APIs, including support for ARM64 architecture.
.NET 8Cross-platformContinuing to evolve cross-platform support, toolset improvements, and performance optimizations.
.NET 9Cross-platformEnhanced performance, AI integration, improved JSON serialization, and new LINQ methods, alongside better support for Arm64 and MAUI updates.
.NET 10Cross-PlatformThe 2026 Standard. Deep focus on Green computing (low battery use) and C# 14 features.

To understand c# you must see it as two separate parts

  • The Language Design (Architects)
  • The Implementation ( Builders)

The Language Design

  • Organization: ECMA International Standard ECM-334
  • The Team : The C# Language Design Team(LDT) at Microsoft works with an international Committee (TC49-TG2) to write the “Official Rules”
  • What they do: They decide the Grammar of language. For example, they decide that an if statement must look like if (condition) {...}
  • Goal: To make C# a Standard. This means if anyone else what to build a C# compiler. they just have to follow the ECMA rules.

The Implementations

  • Organizations: Microsoft, The Mono Project
  • The “Engines”
    • CoreCLR: Microsoft’s high-speed engine for web and Cloud.
    • Mono Runtime: An engine build by the community (now owned by Microsoft).
  • What they do: They take the ECMA rules and build the actual software that talks to the computer’s CPU and memory.

Features And Frameworks


Key Features and Capabilities of C#

  • Object Oriented:
    • C# follows an object-oriented paradigm, supporting key concepts such as classes, inheritance, polymorphism, and abstraction. This helps in organizing code and promoting reusability and maintainability.
  • type Safe
    • C# provides a strong type system, meaning it ensures that objects and variables are used in a manner that aligns with their types, preventing many common errors, such as type mismatches.
  • Cross-Platform(with .net Core)
    • With the introduction of .NET Core and later .NET 5 and beyond, C# has become truly cross-platform, allowing developers to build applications for Windows, macOS, and Linux with a unified runtime.

C# in Game Development

  • Unity: Unity is a widely-used game engine that leverages C# as its primary programming language, making it a popular choice for developing both 2D and 3D games across various platforms.

  • Unreal Engine: Although Unreal Engine predominantly uses C++, it also offers support for C# through .NET integration, providing developers with additional flexibility. ( does not natively support C#)

  • MonoGame: MonoGame is an open-source framework that enables developers to create 2D and 3D games using C#, offering a powerful toolset for game development.

  • Godot Engine: Godot is a free, open-source game engine known for its excellent support of C#, making it a solid choice for developers looking to build games using the language.

C# in mobile APP development

  • Xamarin : Xamarin allows developers to build native mobile apps for iOS, Android, and Windows using C# ( Xamarin ended May 1, 2024 )

  • MAUI : Maui Lets C# developers build native cross-platform apps for iOS, Android, and more.

C# in Web Development

  • ASP.NET : is a mature web framework that allows developers to build dynamic web applications in C#

  • Blazer : blazer is a new web framework that let developers create client-side web apps using C#

  • SignalR : SignalR is a C# library for adding real-time bidirectional communication capabilities to web apps.

  • Web API : C# can be used to build RESTful APIs and microservices to power modern web applications

Why is C# is so popular Today

  • Enterprise Adoption : C# has become a dominant language in enterprise software development, powering many mission-critical applications.

  • Versatility : the language’s broad capabilities allow it to be used in a wide range of domains, from games to mobile apps.

  • Rich Ecosystem : The .NET ecosystem provides a wealth of libraries with NuGet, tools, and frameworks to support C# developers.

.NET Execution Journey


Running C# code: To run a C# code you need two main components

  1. Compiler
  2. Runtime Environment

Compiler

  • Translates C# source code into an intermediate format called Common Intermediate Language (CIL) / Intermediate Language (IL)
  • Compiler for C#: csc (C# Compiler), which is part of the .NET SDK
  • Output: Generates an assembly file (e.g., .exe or .dll) ( C# .exe is not normal .exe )

Two main Compilers CSC and Roslyn

Featurecsc (Classic)Roslyn (Modern)
PurposeOriginal C# compilerModern, open-source C# compiler
Introduced.NET Framework 1.0.NET Framework 4.5+ (2015)
PlatformWindows (mostly)Cross-platform (via .NET SDK)
.NET Versions Supported.NET Framework (up to 4.x).NET Framework, .NET Core, .NET 5/6/7/8/9/10+
C# Language VersionsSupports older C# versions (1.0–5.0)Supports newer C# versions (6+)
ToolingBasic compilerRich tooling with diagnostics, IntelliSense, and IDE integration
Runtime IntegrationTied to .NET Framework runtimeTied to .NET Core/.NET runtime
Use CasesLegacy Windows applicationsModern .NET applications, IDEs, and build systems
Open SourceNoYes (part of .NET Foundation)
Unity(2018-Present): Unity switched to the Roslyn Compiler (provided by Microsoft).

old days unity use mcs (the mono c# compiler) - which is open source built by the mono team “Unity has replaced its old, custom compiler with the industry-standard Roslyn compile

  • C# Source Code (.cs):
    • This is the C# code you write (e.g., Program.cs). “Traditional” Style
using System;

public class HelloWorld
{
    public static void Main()
    {
        Console.WriteLine("Hello, IL!");
    }
}

Top-Level Statement

	 // modern c#, even if you only write one line of code. the roslyn compiler treates it as if you have typed the entire "classic" structure
	 Console.WriteLine("Hello, IL!");
  • C# Compiler (Roslyn or csc):

    • The C# compiler (either Roslyn for .NET Core or csc for .NET Framework) compiles the C# code into Intermediate Language (IL).
    • IL code is bytecode. It’s a set of platform-agnostic instructions (much like assembly language) that the .NET runtime can understand.
    • The output is an EXE or DLL file that contains this IL code.
  • IL Code:

    • IL (Intermediate Language) is a low-level language that’s not tied to a specific hardware or operating system.
    • It’s stored in DLL or EXE files.
    • It can be thought of as a higher-level assembly language that’s meant to be processed by the runtime. IL code (Example)
.assembly extern mscorlib { }
.assembly HelloWorld { }
.module HelloWorld.exe
.namespace HelloWorld
{
    .class public auto ansi beforefieldinit HelloWorld
        extends [mscorlib]System.Object
    {
        .method public hidebysig static void Main() cil managed
        {
            .entrypoint
            // Code size       17 (0x11)
            .maxstack  1
            IL_0000:  ldstr      "Hello, IL!"
            IL_0005:  call       void [mscorlib]System.Console::WriteLine(string)
            IL_000a:  nop
            IL_000b:  ret
        } // end of method HelloWorld::Main
    } // end of class HelloWorld
}

Runtime Environment (CLR - common language Runtime)


CLR as a “Virtual Manager” that stays active the entire time your program is running. It doesn’t just start the app. its supervises everything.

  • CLR:

    • The CLR (in .NET Framework) or CoreCLR (in .NET Core/5/6+) is the runtime that loads and executes the IL code.
    • The runtime provides services like memory management, garbage collection, and type safety.
    • Just like Java applications require the Java Runtime Environment (JRE) to run, .NET applications need the .NET Runtime, which includes the CLR, libraries, and supporting tools.
  • JIT Compilation (Just-In-Time Compilation):

    • The CLR uses a JIT compiler to translate the IL code into native machine code (specific to the platform) when the program is running (at runtime).
    • This is where IL code gets translated into something that can be executed on the specific platform’s processor (like Intel, ARM, etc.).
  • Native Code:

    • This is the machine code that your CPU can execute directly. It’s the result of the JIT compilation process.

Steps

  1. Loading the Assembly When you run the program, the CLR opens the .exe or .dll it checks the metadata to make sure the file is safe and understands what other libraries (like system) it needs to talk to.

  2. JIT Compilation (The heart of the Runtime) The CPU cannot read IL code. The CLR contains a JIT (Just-in-time) compiler.

    • Action: As code runs, the JIT translates the IL into Native Machine code specific to hardware.
    • It only compiles the parts of the code the user is actually using right now. This make the program start faster and save memory.
  3. Managed Services (The supervisor) While the CPU is executing the machine code, the CLR provides Managed Services to keep things running smoothly:

    • Garbage Collection (GC) : it automatically clean up memory that your program no longer needs. You don’t have to manually delete data like in older languages.
    • Type Safety : It makes sure your code doesn’t try to put a “word” into a “Number” box by mistake, preventing crashes.
    • Exception Handling: It manages errors so that one small mistake doesn’t crash the entire computer.
PlatformCompilerRuntimeJIT CompilationOutputKey Notes
.NET Framework(formerly CSC)CLR (Common Language Runtime)Yes, using CLR JIT CompilerEXE/DLL (IL Code)Initially used CSC compiler, now uses Roslyn. Supports desktop applications.
.NET CoreRoslynCoreCLR (Cross-platform CLR)Yes, using CoreCLR JIT CompilerEXE/DLL (IL Code)Designed for cross-platform apps. CoreCLR is lighter and optimized.
.NET 5+Roslyn.CoreCLR Runtime (unified platform)Yes, using JIT CompilationEXE/DLL (IL Code)Unified version of .NET Core and .NET Framework for cross-platform apps.
Monomcs ( Mono C# Compiler) (legacy) or RoslynMono RuntimeYes, using Mono’s JIT CompilerEXE/DLL (IL Code)Initially used mcs but now supports Roslyn. Primarily cross-platform.