.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()Determines whether the specified object is equal to the current object.
obj
: The object to compare with the current object.
true
if the specified object is equal to the current object; otherwise, false
.Serves as the default hash function.
System.Int32
: A hash code for the current object.Gets the runtime type of the current instance.
System.Type
: The type of the current instance.Returns a string that represents the current object.
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.
Gets the number of characters in the current string
object.
System.Int32
: The number of characters in the current string.Gets the character at the specified position in the current string
object.
index
: A zero-based index of the character to retrieve.
char
: The character at the specified position.Concatenates the specified strings.
str0
: The first string to concatenate.str1
: The second string to concatenate.
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()Gets the number of elements actually contained in the List<T>
.
Gets or sets the element at the specified index.
index
: The zero-based index of the element to get or set.
Adds an object to the end of the List<T>
.
item
: The object to be added to theList<T>
. The value can benull
for reference types.
Removes the element at the specified index of the List<T>
.
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.
path
: The file to read.
System.String
: The content of the file.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.
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.
ipString
: A string that contains an IP address.
IPAddress
: An IPAddress
instance.Converts the string representation of an IP address into an IPAddress
instance. A return value indicates whether the conversion succeeded or failed.
ipString
: A string that contains an IP address.address
: If the conversion succeeds, the parameter contains the converted IP address; otherwise,null
.
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.
millisecondsTimeout
: The number of clock ticks to wait. The value can range from 0 toInt32.MaxValue
.
Example
Console.WriteLine("Starting delay...");
Thread.Sleep(2000); // Pause for 2 seconds
Console.WriteLine("Delay finished.");