.NET API Reference

Namespace: System

Provides fundamental classes and base types that define value types, references types, and special object types that are used throughout the .NET framework.

Class: Object

public class Object

Supports all classes, the root of the class hierarchy.

Methods:

  • public bool Equals(object obj)

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

  • public int GetHashCode()

    Serves as the default hash function.

  • public string ToString()

    Returns a string that represents the current object.

Class: String

public sealed class String : IComparable, ICloneable, IConvertible, IEnumerable, IEnumerable<char>, IList<char>, IStructuralComparable, IStructuralEquatable

Represents text as a sequence of UTF-16 code units.

Methods:

  • public static string Concat(string str0, string str1)

    Concatenates two strings.

  • public int IndexOf(char value)

    Reports the zero-based index of the first occurrence of a specified Unicode character within this instance.

  • public string Substring(int startIndex)

    Retrieves a substring from this instance. The substring retrieves the characters from a specified position in this instance to the end of the instance.

Example:


string greeting = "Hello";
string name = "World";
string message = string.Concat(greeting, ", ", name, "!");
// message is "Hello, World!"
                        

Struct: Int32

public struct Int32 : IComparable, IComparable<int>, IConvertible, IEquatable<int>

Represents a 32-bit signed integer.

Methods:

  • public static int Parse(string s)

    Converts the string representation of a number to its 32-bit signed integer equivalent.

  • public bool TryParse(string s, out int result)

    Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded or failed.

Class: Exception

[Serializable] public abstract class Exception : _Exception

Represents errors that occur during application execution.

Properties:

  • public string Message { get; }

    Gets a message that describes the current exception.

Methods:

  • public virtual void Throw()

    Throws the current exception.

Namespace: System.Collections

Contains interfaces and classes that define collections of objects.

Class: ArrayList

[Serializable] public class ArrayList : IList, ICollection, IEnumerable

Represents a non-generic collection of object references that can be individually accessed by an integer index.

Methods:

  • public virtual int Add(object value)

    Adds an object to the end of the ArrayList.

Class: List<T>

[Serializable] public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable

Represents a strongly typed list of objects that can be accessed by index. Provides methods for manipulating the list.

Methods:

  • public void Add(T item)

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

  • public bool Contains(T item)

    Determines whether an element is in the List<T>.

Example:


List<string> names = new List<string>();
names.Add("Alice");
names.Add("Bob");
bool hasCharlie = names.Contains("Charlie"); // false
                        

Namespace: System.Linq

Supports language-integrated query (LINQ), which provides powerful, query-like capabilities to .NET languages.

Class: Enumerable

public static class Enumerable

Provides a set of static methods for querying collections that support IEnumerable<T>.

Methods:

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

    Filters a sequence of values based on a predicate.

  • public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)

    Projects each element of a sequence into a new form.

Example:


List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6 };
var evenNumbers = numbers.Where(n => n % 2 == 0);
// evenNumbers contains { 2, 4, 6 }
                        

Namespace: System.Net

Provides classes that enable developers to easily send or receive information using the Internet.

Namespace: System.Net.Http

Provides classes for sending HTTP requests and receiving HTTP responses.

Classes:

Class: HttpClient

public class HttpClient : IDisposable

Provides a base class for sending HTTP requests and receiving HTTP responses from a resource identified by a URI.

Methods:

  • public Task<HttpResponseMessage> GetAsync(string requestUri)

    Send a GET request to the specified Uri and receive the response.

Example:


using (HttpClient client = new HttpClient())
{
    HttpResponseMessage response = await client.GetAsync("https://example.com");
    response.EnsureSuccessStatusCode(); // Throw if not success
    string responseBody = await response.Content.ReadAsStringAsync();
    Console.WriteLine(responseBody);
}