.NET Fundamentals

What is .NET?

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

It's a developer platform that includes tools, languages, and libraries for building applications.

Key .NET Components

Understanding the core components of the .NET ecosystem is crucial for effective development.

Runtime (CLR)

The Common Language Runtime (CLR) is the execution engine of .NET. It provides core services such as:

Base Class Library (BCL)

The Base Class Library (BCL) provides a set of fundamental types and functionalities that developers can use to build applications. This includes:

Languages

.NET supports multiple programming languages, with C# being the most prominent. Other supported languages include F# and Visual Basic.

Common Intermediate Language (CIL)

Source code written in .NET languages is compiled into Common Intermediate Language (CIL), also known as Microsoft Intermediate Language (MSIL). CIL is a CPU-agnostic, platform-agnostic instruction set that the CLR then compiles into native machine code.

.NET Standard

.NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementations. It acts as a contract to ensure that libraries built for .NET Standard can run on any .NET implementation that supports that version of the Standard.

Common Tasks and Examples

Here are some basic examples of common tasks in .NET.

Hello, World! in C#

A simple console application example:

using System;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello, .NET World!");
    }
}

Using Collections

Demonstrates using a List from the BCL:

using System;
using System.Collections.Generic;

public class CollectionExample
{
    public static void Main(string[] args)
    {
        List names = new List();
        names.Add("Alice");
        names.Add("Bob");
        names.Add("Charlie");

        Console.WriteLine("Names:");
        foreach (string name in names)
        {
            Console.WriteLine($"- {name}");
        }
    }
}