DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="3.3.1" />

 Intrinsics

public static class Intrinsics
Represents highly optimized runtime intrinsic methods.
public static IntPtr AddressOf<T>(ref T value)

Returns an address of the given by-ref parameter.

public static bool AreSame<T>(ref T first, ref T second)

Indicates that two managed pointers are equal.

public static ref T AsRef<T>(this TypedReference reference)

Converts typed reference into managed pointer.

public static void Bitcast<T, TResult>(ref T input, out TResult output) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType) where TResult : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Obtain a value of type TResult by reinterpreting the object representation of T.

public static T Cast<T>(object obj)

Provides unified behavior of type cast for reference and value types.

public static void ClearBits(Void* address, long length)

Sets all bits of allocated memory to zero.

public static int Compare(Void* first, Void* second, long length)

Bitwise comparison of two memory blocks.

public static void Copy<T>(ref T input, out T output) where T : struct

Copies one value into another.

public static void Copy<T>(T* input, T* output) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Copies one value into another.

public static void Copy<T>(ref T source, out T destination, long count) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Copies the specified number of elements from source address to the destination address.

public static void CopyUnaligned<T>(T* input, T* output) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Copies one value into another assuming unaligned memory access.

public static T DefaultOf<T>()

Returns default value of the given type.

public static bool Equals(Void* first, Void* second, long length)

Computes equality between two blocks of memory.

public static Exception Error(object obj)

Throws arbitrary object as exception.

public static T GetElement<T>(T[] array, IntPtr index)

Gets an element of the array by its index.

public static T GetElement<T>(T[] array, UIntPtr index)

Gets an element of the array by its index.

public static ref T GetElementReference<T>(T[] array, IntPtr index)

Gets the address of the array element.

public static ref T GetElementReference<T>(T[] array, UIntPtr index)

Gets the address of the array element.

public static int GetHashCode32<T>(Func<T, int, int> getter, int count, T arg, bool salted = true)

Computes 32-bit hash code for the vector.

public static int GetHashCode32(Void* source, long length, int hash, Func<int, int, int> hashFunction, bool salted = true)

Computes 32-bit hash code for the block of memory.

public static int GetHashCode32<THashFunction>(Void* source, long length, int hash, THashFunction hashFunction, bool salted = true) where THashFunction : struct, ISupplier<int, int, int>

Computes 32-bit hash code for the block of memory.

public static int GetHashCode32(Void* source, long length, bool salted = true)

Computes 32-bit hash code for the block of memory.

public static long GetHashCode64<T>(Func<T, int, long> getter, int count, T arg, bool salted = true)

Computes 64-bit hash code for the vector.

public static long GetHashCode64(Void* source, long length, long hash, Func<long, long, long> hashFunction, bool salted = true)

Computes 64-bit hash code for the block of memory, 64-bit version.

public static long GetHashCode64<THashFunction>(Void* source, long length, long hash, THashFunction hashFunction, bool salted = true) where THashFunction : struct, ISupplier<long, long, long>

Computes 64-bit hash code for the block of memory, 64-bit version.

public static long GetHashCode64(Void* source, long length, bool salted = true)

Computes 64-bit hash code for the block of memory.

public static IntPtr GetLength(Array array)

Gets length of the zero-base one-dimensional array.

public static TBase& modreq(System.Runtime.InteropServices.InAttribute) GetReadonlyRef<T, TBase>(this T[] array, IntPtr index) where T : TBase

Allows to reinterpret managed pointer to array element.

public static bool HasFlag<T>(T value, T flag) where T : struct, Enum

Determines whether one or more bit fields are set in the given value.

public static bool IsDefault<T>(ref T value)

Indicates that specified value type is the default value.

public static bool IsExactTypeOf<T>(object obj)

Checks whether the specified object is exactly of the specified type.

public static bool IsNullable<T>()

Provides the fast way to check whether the specified type accepts null value as valid value.

public static int PointerHashCode(Void* pointer)

Computes transient hash code of the specified pointer.

public static void Reverse<T>(ref T value) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Reverse bytes in the specified value of blittable type.

public static T ShallowCopy<T>(T obj)

Creates shallow copy of the given object.

public static void Swap<T>(ref T first, ref T second)

Swaps two values.

public static void Swap<T>(T* first, T* second) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Swaps two values.

public static void Throw(object obj)

Throws arbitrary object as exception.

public static void ThrowIfNull<T>(ref T value)

Throws NullReferenceException if given managed pointer is null.

public static int ToInt32(bool low, bool high)

Converts two bits to 32-bit signed integer.

public static RuntimeTypeHandle TypeOf<T>()

Returns the runtime handle associated with type T.