.NET API Reference (net)

Welcome to the .NET API documentation. This section covers core namespaces and types within the .NET ecosystem.

System

Provides fundamental classes and base types that define commonly used value and reference data types, exceptions, and other runtime support.

Object

Defines the root of all classes in the .NET Framework; the universally inherited record of all objects.

Object()
Constructor
bool Equals(Object obj)

Determines whether the specified object is equal to the current object.

Parameters:
  • obj: The object to compare with the current object.
Returns true if the specified object is equal to the current object; otherwise, false.
int GetHashCode()

Serves as the default hash function.

Returns System.Int32: A hash code for the current object.
Type GetType()

Gets the runtime type of the current instance.

Returns System.Type: The type of the current instance.
string ToString()

Returns a string that represents the current object.

Returns System.String: A string that represents the current object.

String

Represents text as a sequence of characters. All operations on a string create a new string object, as strings in .NET are immutable.

int Length { get; }

Gets the number of characters in the current string object.

Returns System.Int32: The number of characters in the current string.
char this[int index] { get; }

Gets the character at the specified position in the current string object.

Parameters:
  • index: A zero-based index of the character to retrieve.
Returns char: The character at the specified position.
static string Concat(string str0, string str1)

Concatenates the specified strings.

Parameters:
  • str0: The first string to concatenate.
  • str1: The second string to concatenate.
Returns System.String: The concatenated string.

Example

string greeting = "Hello";
string name = "World";
string message = string.Concat(greeting, ", ", name, "!");
Console.WriteLine(message); // Output: Hello, World!

System.Collections

Defines interfaces and classes that define various collections of objects.

List<T>

Represents a strongly typed list of objects that can be accessed by index. Provides methods for creating, searching, and manipulating lists.

List()
Constructor
int Count { get; }

Gets the number of elements actually contained in the List<T>.

T this[int index] { get; set; }

Gets or sets the element at the specified index.

Parameters:
  • index: The zero-based index of the element to get or set.
void Add(T item)

Adds an object to the end of the List<T>.

Parameters:
  • item: The object to be added to the List<T>. The value can be null for reference types.
void RemoveAt(int index)

Removes the element at the specified index of the List<T>.

Parameters:
  • index: The zero-based index of the element to remove.

Example

var numbers = new List<int>();
numbers.Add(10);
numbers.Add(20);
numbers.Add(30);
Console.WriteLine($"First element: {numbers[0]}"); // Output: First element: 10
numbers.RemoveAt(1); // Removes 20
Console.WriteLine($"Count: {numbers.Count}"); // Output: Count: 2

System.IO

Contains types that allow reading and writing to streams and files.

File

Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in their creation.

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.
Returns System.String: The content of the file.
static void WriteAllText(string path, string contents)

Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is overwritten.

Parameters:
  • path: The file to write to.
  • contents: The string to write to the file.

Example

string filePath = "mydata.txt";
string textToWrite = "This is a test.";
File.WriteAllText(filePath, textToWrite);

string readText = File.ReadAllText(filePath);
Console.WriteLine($"Content: {readText}"); // Output: Content: This is a test.

System.Net

Provides the network communication classes.

IPAddress

Represents an Internet Protocol (IP) address.

static IPAddress Parse(string ipString)

Converts an IPv4 or IPv6 string representation of an IP address into an IPAddress instance.

Parameters:
  • ipString: A string that contains an IP address.
Returns IPAddress: An IPAddress instance.
static bool TryParse(string ipString, out IPAddress address)

Converts the string representation of an IP address into an IPAddress instance. A return value indicates whether the conversion succeeded or failed.

Parameters:
  • ipString: A string that contains an IP address.
  • address: If the conversion succeeds, the parameter contains the converted IP address; otherwise, null.
Returns bool: true if the conversion succeeded; otherwise, false.

System.Threading

Contains types that simplify programming with threads and managing concurrent operations.

Thread

Represents a thread of execution in the common language runtime.

static void Sleep(int millisecondsTimeout)

Suspends the current thread for the specified number of milliseconds.

Parameters:
  • millisecondsTimeout: The number of clock ticks to wait. The value can range from 0 to Int32.MaxValue.

Example

Console.WriteLine("Starting delay...");
Thread.Sleep(2000); // Pause for 2 seconds
Console.WriteLine("Delay finished.");