.NET Core API Documentation

Welcome to the comprehensive documentation for the .NET Core APIs. This section provides detailed information about the core libraries and namespaces that form the foundation of .NET Core development. Explore the available classes, methods, and types to build powerful and efficient applications.

Core API Overview

The .NET Core platform is built upon a rich set of fundamental libraries that enable a wide range of programming tasks. These libraries are organized into namespaces, each focusing on specific functionalities.

System Namespace

The System namespace is the root of many fundamental types and services used in .NET development. It provides essential classes for working with primitive types, collections, input/output operations, and much more.

System.Collections

This namespace provides interfaces and classes that define various collections of objects, such as lists, dictionaries, and queues. These are crucial for managing groups of related objects.

  • IList<T> interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable

    Represents a strongly typed list of objects that can be accessed by index. Inherits from ICollection<T>.

  • Dictionary<TKey, TValue> class Dictionary<TKey, TValue> : ICollection<KeyValuePair<TKey, TValue>>, ICollection, IDictionary<TKey, TValue>, IDictionary, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IReadOnlyDictionary<TKey, TValue>

    Represents a collection of key/value pairs that are organized by key. This is an efficient way to look up values by their unique keys.

System.IO

The System.IO namespace provides types that allow reading and writing to files and data streams, as well as types that represent and manipulate various kinds of files and directories.

  • File class File

    Provides static methods for the creation, copying, deletion, moving, and opening of files. It also provides FileStream objects for other file operations.

    // Example: Reading a file
    using System.IO;
    
    string content = File.ReadAllText("myFile.txt");
    Console.WriteLine(content);
  • StreamWriter class StreamWriter : TextWriter

    Implements a TextWriter for writing characters to a stream in a particular encoding. Useful for writing text-based data to files.

System.Text

This namespace contains classes for representing character encodings, and for reading and writing sequences of characters.

  • StringBuilder class StringBuilder

    Provides a mutable sequence of characters. This class is useful for performing many modifications to a string without creating a new string object for each modification.

    // Example: Using StringBuilder
    using System.Text;
    
    StringBuilder sb = new StringBuilder();
    sb.Append("Hello");
    sb.Append(" ");
    sb.Append("World!");
    string result = sb.ToString(); // "Hello World!"
  • Encoding abstract class Encoding

    Represents a character encoding. Encoding classes abstract the process of converting between character representations and sequences of bytes.

Microsoft.Extensions Namespace

This namespace and its sub-namespaces contain extensions and utilities commonly used in modern .NET applications, especially those built with ASP.NET Core and other framework components.

Microsoft.Extensions.DependencyInjection

Provides types for abstracting the process of dependency injection, allowing for flexible and maintainable application architecture.

  • IServiceCollection interface IServiceCollection : ICollection<ServiceDescriptor>

    Represents a collection of service descriptors that can be used to register services with a dependency injection container.

  • ServiceCollection class ServiceCollection : IServiceCollection

    An implementation of IServiceCollection that can be used to register services.

Microsoft.Extensions.Logging

Defines interfaces and abstractions for logging within .NET applications, supporting various logging providers.

  • ILoggerFactory interface ILoggerFactory

    Represents a factory for creating instances of ILogger.

  • ILogger<TCategoryName> interface ILogger<out TCategoryName> : ILogger

    Represents a general-purpose logging abstraction. TCategoryName is the type used to resolve the category name that will be used when writing log messages.

    // Example: Logging
    using Microsoft.Extensions.Logging;
    
    public class MyService
    {
        private readonly ILogger<MyService> _logger;
    
        public MyService(ILogger<MyService> logger)
        {
            _logger = logger;
        }
    
        public void DoSomething()
        {
            _logger.LogInformation("Doing something...");
        }
    }

Further Reading

For more in-depth information and detailed examples, please refer to the official Microsoft .NET documentation website.

Explore the Full .NET API Browser