.NET API Reference

Welcome to the .NET API Reference

Explore the vast landscape of the .NET framework's classes, methods, properties, and more. This comprehensive documentation allows you to quickly find the information you need to build powerful applications.

Use the navigation pane on the left to browse namespaces and types, or utilize the search bar to find specific members.

System.Collections

Contains interfaces and classes that define groups of elements, such as collections and lists. This namespace includes non-generic collection types.

ArrayList

Represents a strongly typed list of objects that can be accessed by index. It implements the IList interface and is a dynamic array.

Remarks

  • ArrayList is not type-safe. You must manually ensure that elements are of the correct type.
  • For type-safe collections, use the generic classes in the System.Collections.Generic namespace.

Hashtable

Represents a collection of key-value pairs that are organized based on the hash code of the key. It is not type-safe.

Remarks

  • Keys and values can be any type.
  • Use Dictionary<TKey, TValue> for type-safe dictionaries.

System.Collections.Generic

Contains interfaces and classes that define generic collections, which allow developers to create strongly typed collections that improve performance and reduce runtime errors.

List<T>

Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.

Syntax
public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>

Type Parameters

  • T: The type of elements in the list.

Remarks

  • The capacity of a List<T> can grow as elements are added.
  • Use this class for type-safe collections.

Dictionary<TKey, TValue>

Represents a collection of key/value pairs that are organized by key. Provides efficient access to elements by key.

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

Type Parameters

  • TKey: The type of keys in the dictionary.
  • TValue: The type of values in the dictionary.

Remarks

  • Keys must be unique.
  • The default capacity is 0. As elements are added, the capacity is increased by doubling.

System.IO

Provides types that allow reading and writing to files and data streams, and types that handle various file and directory operations.

File

Provides static properties and instance methods for the creation, copying, deletion, moving, and opening of files.

static string ReadAllText(string path)

Opens a text file, reads all lines of the file, and then closes the file.

Parameters

  • path: The file to read.

Return Value

string: The contents of the file.

// Example usage: string filePath = "myFile.txt"; string content = File.ReadAllText(filePath); Console.WriteLine(content);

Directory

Provides static properties and instance methods for the creation, moving, and enumeration of directories and subdirectories.

static void CreateDirectory(string path)

Creates all directories and subdirectories in the specified path unless they already exist.

Parameters

  • path: The directory to create.
// Example usage: string newDir = @"C:\MyNewFolder"; Directory.CreateDirectory(newDir);

System.Linq

Provides classes and interfaces that support language-integrated query (LINQ), including methods for querying collections and other data sources.

Enumerable

Supports the development of LINQ to Objects, which enables queries to be written for any IEnumerable<T> collection.

static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)

Filters a sequence of values based on a predicate.

Syntax
public static IEnumerable<TSource> Where<TSource>(IEnumerable<TSource> source, Func<TSource, bool> predicate)

Parameters

  • source: An IEnumerable<T> to filter.
  • predicate: A function to test each element for a condition.

Return Value

IEnumerable<TSource>: An IEnumerable<T> that contains elements from the input sequence that satisfy the condition.

// Example usage: List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6 }; IEnumerable<int> evenNumbers = numbers.Where(n => n % 2 == 0); // evenNumbers will contain { 2, 4, 6 }

System.Text

Provides fundamental classes for representing strings and characters, as well as classes for text encoding and decoding.

StringBuilder

Represents a mutable sequence of characters.

Syntax
public class StringBuilder

StringBuilder Append(string value)

Appends the string representation of a value to this instance.

Parameters

  • value: The string to append.

Return Value

StringBuilder: A reference to this instance after the append operation has completed.

// Example usage: StringBuilder sb = new StringBuilder(); sb.Append("Hello"); sb.Append(" "); sb.Append("World!"); string result = sb.ToString(); // result is "Hello World!"

Microsoft.Extensions.DependencyInjection

Provides types for the .NET dependency injection container.

ServiceCollection

Represents a collection of service descriptors.

void AddTransient<TService>()

Adds a transient service with an implementation of the specified generic type to the specified services collection.

Syntax
public void AddTransient<TService>() where TService : class

Type Parameters

  • TService: The type of the service to add.

Microsoft.Extensions.Logging

Provides types for logging in .NET applications.

ILogger

Represents a generic logging interface.

void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)

Logs a message.

Parameters

  • logLevel: The log level.
  • eventId: The event identifier.
  • state: The information to log.
  • exception: The exception to log.
  • formatter: A function to format the log message.

System.Xml.Linq

Provides classes for the LINQ to XML API, which allows you to query and manipulate XML data using LINQ.

XDocument

Represents an XML document.

static XDocument Load(string uri)

Loads an XML document from the specified uri.

Parameters

  • uri: The URI to load the XML document from.

Return Value

XDocument: An XDocument that contains the XML document.

// Example usage: XDocument doc = XDocument.Load("http://example.com/data.xml");