C# (.NET) Standard Library: Complete Overview
The .NET Standard Library (Base Class Library, BCL) is the fundamental foundation for C# development. It provides thousands of ready-made classes, interfaces, structures, and enumerations that cover virtually all aspects of programming: from working with numbers and strings to network interaction and database access. In this overview, we will look at the key namespaces and their capabilities.
System Namespace: The Foundation
The System namespace contains the basic data types used in all C# applications. These include:
- Primitive types:
Boolean,Byte,Int32,Double,Char,String, and others. Each has methods for conversion, comparison, and formatting. Mathclass: provides constants (π, e) and static methods for trigonometric, logarithmic, and statistical calculations.Convertclass: allows safe type conversion (e.g., string to number).Consoleclass: manages input/output in a console application.
using System;
int a = 42;double b = Math.Sqrt(a);string text = Convert.ToString(a);Console.WriteLine($"The square root of {text} is {b}");System.Collections and System.Collections.Generic: Working with Collections
These namespaces contain classes for storing and managing groups of objects. Modern applications should use the generic versions from System.Collections.Generic, as they provide type safety and higher performance.
List<T>— dynamic array.Dictionary<TKey, TValue>— key-value collection.Queue<T>andStack<T>— queue and stack implementations.HashSet<T>— set of unique elements.
using System.Collections.Generic;
var numbers = new List<int> { 1, 2, 3, 4, 5 };numbers.Add(6);numbers.Remove(3);
var map = new Dictionary<string, int>{ { "one", 1 }, { "two", 2 }};
if (map.ContainsKey("one")) Console.WriteLine(map["one"]);System.Linq: Language Integrated Query
LINQ (Language Integrated Query) allows you to query collections, databases, XML, and other data sources using a unified syntax. The main extension methods are defined in the System.Linq namespace:
Where— filtering.Select— projection.OrderBy/ThenBy— sorting.GroupBy— grouping.Aggregate,Sum,Count— aggregate operations.
using System.Linq;
int[] scores = { 85, 92, 78, 95, 88 };var highScores = scores .Where(s => s >= 90) .OrderByDescending(s => s) .Select(s => $"Score: {s}");
foreach (var item in highScores) Console.WriteLine(item);System.IO: Working with the File System and Streams
The System.IO namespace provides classes for reading/writing files, working with directories, and managing data streams. Main classes:
FileandFileInfo— static and instance methods for working with files.DirectoryandDirectoryInfo— folder management.StreamReader/StreamWriter— reading and writing text files.
Also in library
Working with Dates in Kotlin: Libraries and Tools for Development
PHP Application Monitoring: Tools and Libraries for Performance Tracking
Working with Images in TypeScript: resize and crop with Sharp and Jimp
Java Application Monitoring: Tools and Libraries for Metric Collection
Working with CSV in TypeScript: Libraries and Code Examples