C# (.NET) Standard Library: Complete Overview of Features

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

C# (.NET) Standard Library: Complete Overview



The .NET Standard Library (Base Class Library, BCL) is a fundamental set of classes, interfaces, and value types that are part of the .NET platform. It provides C# developers with ready-made components for solving common tasks: from working with collections and files to network interaction and asynchronous programming. In this article, we will take a detailed look at the key namespaces and classes that every C# developer should know.



1. System Namespace — The Foundation of Everything

The root namespace System contains fundamental types:

  • Base Data Types: Object, String, Int32, Double, Boolean, etc.
  • Utilities: Console (input/output), Math (mathematical functions), Random (random number generation).
  • Error Handling: Exception and its descendants (ArgumentException, NullReferenceException, etc.).

Usage example:

using System;

class Program{ static void Main() { Console.WriteLine("Hello, .NET!"); double result = Math.Sqrt(144); Console.WriteLine($"Square root of 144: {result}"); }}


2. System.Collections — Working with Collections

A namespace for storing and managing groups of objects. It is divided into generic and non-generic collections.

Main Classes:

  • List<T> — a dynamic array with fast index-based access.
  • Dictionary<TKey, TValue> — an associative array (hash table).
  • Queue<T> — a queue (FIFO).
  • Stack<T> — a stack (LIFO).
  • HashSet<T> — a set of unique elements.

Example:

using System.Collections.Generic;

var numbers = new List<int> { 10, 20, 30 };numbers.Add(40);

var lookup = new Dictionary<string, int>{ ["one"] = 1, ["two"] = 2};

Console.WriteLine(lookup["two"]); // 2


3. System.Linq — Language Integrated Query

LINQ allows you to execute SQL-like queries against collections, databases, and XML. Main extension methods:

  • Where() — filtering.
  • Select() — projection.
  • OrderBy() — sorting.
  • GroupBy() — grouping.
  • Aggregate() — aggregate functions (Sum, Count, Average).

Example:

using System.Linq;

int[] scores = { 85, 92, 78, 95, 88 };var highScores = scores .Where(s => s >= 90) .OrderByDescending(s => s) .ToList();

Console.WriteLine(string.Join(", ", highScores)); // 95, 92


4. System.IO — Working with Files and Streams

A namespace for data input/output. Key classes:

  • File / FileInfo — creating, reading, writing files.
  • Directory / DirectoryInfo — working with directories.
  • StreamReader / StreamWriter — reading/writing text streams.
  • FileStream — low-level file operations.

Example of writing and reading:

using System.IO;

string path = "example.txt";File.WriteAllText(path, "Hello, .NET!");

string content = File.ReadAllText(path);Console.WriteLine(content); // Hello, .NET!


5. System.Threading.Tasks — Asynchronous Programming

A modern approach to asynchrony using the async and await keywords. Main classes

Recommendations