<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0-preview.2.20160.6" />

Unsafe

public static class Unsafe
Contains generic, low-level functionality for manipulating pointers.
public static ref T Add<T>(ref T source, int elementOffset)

Adds an element offset to the given reference.

public static Void* Add<T>(Void* source, int elementOffset)

Adds an element offset to the given void pointer.

public static ref T Add<T>(ref T source, IntPtr elementOffset)

Adds an element offset to the given reference.

public static ref T AddByteOffset<T>(ref T source, IntPtr byteOffset)

Adds a byte offset to the given reference.

public static bool AreSame<T>(ref T left, ref T right)

Determines whether the specified references point to the same location.

public static T As<T>(object o)

Casts the given object to the specified type.

public static ref TTo As<TFrom, TTo>(ref TFrom source)

Reinterprets the given reference as a reference to a value of type TTo.

public static Void* AsPointer<T>(ref T value)

Returns a pointer to the given by-ref parameter.

public static ref T AsRef<T>(Void* source)

Reinterprets the given location as a reference to a value of type T.

public static ref T AsRef<T>(ref T source)

Reinterprets the given read-only reference as a reference.

public static IntPtr ByteOffset<T>(ref T origin, ref T target)

Determines the byte offset from origin to target from the given references.

public static void Copy<T>(Void* destination, ref T source)

Copies a value of type T to the given location.

public static void Copy<T>(ref T destination, Void* source)

Copies a value of type T to the given location.

public static void CopyBlock(Void* destination, Void* source, uint byteCount)

Copies bytes from the source address to the destination address.

public static void CopyBlock(ref byte destination, ref byte source, uint byteCount)

Copies bytes from the source address to the destination address.

public static void CopyBlockUnaligned(Void* destination, Void* source, uint byteCount)

Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses.

public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount)

Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses.

public static void InitBlock(Void* startAddress, byte value, uint byteCount)

Initializes a block of memory at the given location with a given initial value.

public static void InitBlock(ref byte startAddress, byte value, uint byteCount)

Initializes a block of memory at the given location with a given initial value.

public static void InitBlockUnaligned(Void* startAddress, byte value, uint byteCount)

Initializes a block of memory at the given location with a given initial value without assuming architecture dependent alignment of the address.

public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount)

Initializes a block of memory at the given location with a given initial value without assuming architecture dependent alignment of the address.

public static bool IsAddressGreaterThan<T>(ref T left, ref T right)

Returns a value that indicates whether a specified reference is greater than another specified reference.

public static bool IsAddressLessThan<T>(ref T left, ref T right)

Returns a value that indicates whether a specified reference is less than another specified reference.

public static T Read<T>(Void* source)

Reads a value of type T from the given location.

public static T ReadUnaligned<T>(Void* source)

Reads a value of type T from the given location without assuming architecture dependent alignment of the addresses.

public static T ReadUnaligned<T>(ref byte source)

Reads a value of type T from the given location without assuming architecture dependent alignment of the addresses.

public static int SizeOf<T>()

Returns the size of an object of the given type parameter.

public static void SkipInit<T>(out T value)

public static ref T Subtract<T>(ref T source, int elementOffset)

Subtracts an element offset from the given reference.

public static Void* Subtract<T>(Void* source, int elementOffset)

Subtracts an element offset from the given void pointer.

public static ref T Subtract<T>(ref T source, IntPtr elementOffset)

Subtracts an element offset from the given reference.

public static ref T SubtractByteOffset<T>(ref T source, IntPtr byteOffset)

Subtracts a byte offset from the given reference.

public static ref T Unbox<T>(object box) where T : struct

Returns a mutable ref to a boxed value.

public static void Write<T>(Void* destination, T value)

Writes a value of type T to the given location.

public static void WriteUnaligned<T>(Void* destination, T value)

Writes a value of type T to the given location without assuming architecture dependent alignment of the addresses.

public static void WriteUnaligned<T>(ref byte destination, T value)

Writes a value of type T to the given location without assuming architecture dependent alignment of the addresses.