Introduction to .NET Core Concepts

Welcome to the foundational concepts of .NET. This guide provides a comprehensive overview of the core components and principles that drive modern .NET development.

What is .NET?

.NET is a free, cross-platform, open-source framework for building many different types of applications. With .NET, you can:

Key characteristics of .NET include:

Core Architecture

.NET's architecture is designed for efficiency, flexibility, and extensibility. It consists of several key layers and components:

The Common Language Runtime (CLR)

The CLR is the execution engine of .NET. It provides essential services like:

When you compile .NET code, it's first converted into an Intermediate Language (IL), also known as Microsoft Intermediate Language (MSIL). The CLR's JIT compiler then translates this IL into native machine code specific to the platform the application is running on.

Software Development Kit (SDK)

The .NET SDK is a set of tools and libraries required to develop .NET applications. It includes:

When you install the .NET SDK, you get everything you need to build and run .NET applications.

Command-Line Interface (CLI)

The .NET CLI is a cross-platform tool that allows you to create, build, test, and publish .NET applications from the command line. Common commands include:


dotnet new console -o MyConsoleApp
cd MyConsoleApp
dotnet build
dotnet run
dotnet publish
            

Assemblies

An assembly is the fundamental unit of deployment, versioning, reuse, activation, and security in .NET. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies are deployed as one or more files, typically ending in .dll or .exe.

Each assembly contains:

Garbage Collection (GC)

Garbage Collection is a process managed by the CLR that automatically reclaims memory occupied by objects that are no longer in use by the application. This significantly simplifies memory management for developers, as they don't need to explicitly allocate and deallocate memory.

The GC works by:

  1. Identifying objects that are no longer reachable from the application's roots.
  2. Moving surviving objects to contiguous memory locations.
  3. Updating references to point to the new locations.
  4. Releasing the memory occupied by unreachable objects.

Types

In .NET, everything is a type. The Base Class Library (BCL) provides a rich set of built-in types, and you can define your own custom types. The fundamental categories of types include:

Understanding the distinction between value types and reference types is crucial for efficient memory usage and correct behavior in your applications.

Last Updated: October 26, 2023