Struct Pointer<T>
CLS-compliant typed pointer for .NET languages without direct support of pointer data type.
Inherited Members
Namespace: DotNext.Runtime.InteropServices
Assembly: DotNext.Unsafe.dll
Syntax
public readonly struct Pointer<T> : IEquatable<Pointer<T>>, IComparable<Pointer<T>>, IStrongBox, ISupplier<nint>, IFunctional<Func<nint>>, ISupplier<nuint>, IFunctional<Func<nuint>>, IPinnable, ISpanFormattable, IFormattable, IComparisonOperators<Pointer<T>, Pointer<T>, bool>, IEqualityOperators<Pointer<T>, Pointer<T>, bool>, IAdditionOperators<Pointer<T>, int, Pointer<T>>, IAdditionOperators<Pointer<T>, long, Pointer<T>>, IAdditionOperators<Pointer<T>, nint, Pointer<T>>, IAdditionOperators<Pointer<T>, nuint, Pointer<T>>, ISubtractionOperators<Pointer<T>, int, Pointer<T>>, ISubtractionOperators<Pointer<T>, long, Pointer<T>>, ISubtractionOperators<Pointer<T>, nint, Pointer<T>>, ISubtractionOperators<Pointer<T>, nuint, Pointer<T>>, IIncrementOperators<Pointer<T>>, IDecrementOperators<Pointer<T>>, IAdditiveIdentity<Pointer<T>, nint>, IAdditiveIdentity<Pointer<T>, nuint> where T : unmanaged
Type Parameters
Name | Description |
---|---|
T | The type of pointer. |
Remarks
Many methods associated with the pointer are unsafe and can destabilize runtime. Moreover, pointer type doesn't provide automatic memory management. Null-pointer is the only check performed by methods.
Constructors
| Edit this page View SourcePointer(nint)
Constructs pointer from nint value.
Declaration
public Pointer(nint ptr)
Parameters
Type | Name | Description |
---|---|---|
nint | ptr | The pointer value. |
Pointer(nuint)
Constructs pointer from nuint value.
Declaration
[CLSCompliant(false)]
public Pointer(nuint ptr)
Parameters
Type | Name | Description |
---|---|---|
nuint | ptr | The pointer value. |
Pointer(T*)
Constructs CLS-compliant pointer from non CLS-compliant pointer.
Declaration
[CLSCompliant(false)]
public Pointer(T* ptr)
Parameters
Type | Name | Description |
---|---|---|
T* | ptr | The pointer value. |
Properties
| Edit this page View SourceAddress
Gets pointer address.
Declaration
public nint Address { get; }
Property Value
Type | Description |
---|---|
nint |
Bytes
Converts this pointer into span of bytes.
Declaration
public Span<byte> Bytes { get; }
Property Value
Type | Description |
---|---|
Span<byte> |
IsAligned
Determines whether this pointer is aligned
to the size of T
.
Declaration
public bool IsAligned { get; }
Property Value
Type | Description |
---|---|
bool |
IsNull
Indicates that this pointer is null.
Declaration
public bool IsNull { get; }
Property Value
Type | Description |
---|---|
bool |
this[nuint]
Gets or sets pointer value at the specified position in the memory.
Declaration
[CLSCompliant(false)]
public ref T this[nuint index] { get; }
Parameters
Type | Name | Description |
---|---|---|
nuint | index | Element index. |
Property Value
Type | Description |
---|---|
T | Array element. |
Remarks
This property doesn't check bounds of the array.
Exceptions
Type | Condition |
---|---|
NullPointerException | This array is not allocated. |
Null
Represents zero pointer.
Declaration
public static Pointer<T> Null { get; }
Property Value
Type | Description |
---|---|
Pointer<T> |
Value
Gets the value stored in the memory identified by this pointer.
Declaration
public ref T Value { get; }
Property Value
Type | Description |
---|---|
T | The reference to the memory location. |
Exceptions
Type | Condition |
---|---|
NullPointerException | The pointer is 0. |
Methods
| Edit this page View SourceAsStream(long, FileAccess)
Returns representation of the memory identified by this pointer in the form of the stream.
Declaration
public Stream AsStream(long count, FileAccess access = FileAccess.ReadWrite)
Parameters
Type | Name | Description |
---|---|---|
long | count | The number of elements of type |
FileAccess | access | The type of the access supported by the returned stream. |
Returns
Type | Description |
---|---|
Stream | The stream representing the memory identified by this pointer. |
Remarks
This method returns Stream compatible over the memory identified by this pointer. No copying is performed.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
As<TOther>()
Reinterprets pointer type.
Declaration
public Pointer<TOther> As<TOther>() where TOther : unmanaged
Returns
Type | Description |
---|---|
Pointer<TOther> | Reinterpreted pointer type. |
Type Parameters
Name | Description |
---|---|
TOther | A new pointer type. |
Exceptions
Type | Condition |
---|---|
GenericArgumentException<T> | Type |
BitwiseCompare(Pointer<T>, nuint)
Bitwise comparison of two memory blocks.
Declaration
[CLSCompliant(false)]
public int BitwiseCompare(Pointer<T> other, nuint count)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | other | The pointer identifies block of memory to be compared. |
nuint | count | The number of elements of type |
Returns
Type | Description |
---|---|
int | Comparison result which has the semantics as return type of CompareTo(object). |
Clear()
Sets value at the address represented by this pointer to the default value of T
.
Declaration
public void Clear()
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
Clear(nuint)
Fill memory with zero bytes.
Declaration
[CLSCompliant(false)]
public void Clear(nuint count)
Parameters
Type | Name | Description |
---|---|---|
nuint | count | Number of elements in the unmanaged array. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
CopyTo(Pointer<T>, nuint)
Copies block of memory from the source address to the destination address.
Declaration
[CLSCompliant(false)]
public void CopyTo(Pointer<T> destination, nuint count)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | destination | Destination address. |
nuint | count | The number of elements to be copied. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
ArgumentNullException | Destination pointer is zero. |
CopyTo(Span<T>)
Copies a block of memory identifier by this pointer to the specified location.
Declaration
public void CopyTo(Span<T> destination)
Parameters
Type | Name | Description |
---|---|---|
Span<T> | destination | The destination memory block. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Destination pointer is zero. |
Equals(object?)
Indicates that this pointer represents the same memory location as other pointer.
Declaration
public override bool Equals(object? other)
Parameters
Type | Name | Description |
---|---|---|
object | other | The object of type Pointer<T> to be compared. |
Returns
Type | Description |
---|---|
bool | true, if this pointer represents the same memory location as other pointer; otherwise, false. |
Overrides
| Edit this page View SourceEquals(T, IEqualityComparer<T>)
Determines whether the value stored in the memory identified by this pointer is equal to the given value.
Declaration
public bool Equals(T other, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
T | other | The value to be compared. |
IEqualityComparer<T> | comparer | The object implementing comparison algorithm. |
Returns
Type | Description |
---|---|
bool | true, if the value stored in the memory identified by this pointer is equal to the given value; otherwise, false. |
Equals<TOther>(Pointer<TOther>)
Indicates that this pointer represents the same memory location as other pointer.
Declaration
public bool Equals<TOther>(Pointer<TOther> other) where TOther : unmanaged
Parameters
Type | Name | Description |
---|---|---|
Pointer<TOther> | other | The pointer to be compared. |
Returns
Type | Description |
---|---|
bool | true, if this pointer represents the same memory location as other pointer; otherwise, false. |
Type Parameters
Name | Description |
---|---|
TOther | The type of the another pointer. |
Fill(T, nuint)
Fills the elements of the array with a specified value.
Declaration
[CLSCompliant(false)]
public void Fill(T value, nuint count)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to assign to each element of the array. |
nuint | count | The length of the array. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is zero. |
GetBoxedPointer()
Gets boxed pointer.
Declaration
[CLSCompliant(false)]
public object GetBoxedPointer()
Returns
Type | Description |
---|---|
object | The boxed pointer. |
See Also
| Edit this page View SourceGetEnumerator(nuint)
Gets enumerator over raw memory.
Declaration
[CLSCompliant(false)]
public Pointer<T>.Enumerator GetEnumerator(nuint length)
Parameters
Type | Name | Description |
---|---|---|
nuint | length | A number of elements to iterate. |
Returns
Type | Description |
---|---|
Pointer<T>.Enumerator | Iterator object. |
GetHashCode()
Computes hash code of the pointer itself (i.e. address), not of the memory content.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The hash code of this pointer. |
Overrides
| Edit this page View SourceGetHashCode(IEqualityComparer<T>)
Computes hash code of the value stored in the memory identified by this pointer.
Declaration
public int GetHashCode(IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEqualityComparer<T> | comparer | The object implementing custom hash function. |
Returns
Type | Description |
---|---|
int | The hash code of the value stored in the memory identified by this pointer. |
GetUnaligned()
Dereferences this pointer, assuming that this pointer is unaligned.
Declaration
public T GetUnaligned()
Returns
Type | Description |
---|---|
T | The value stored in the memory. |
Exceptions
Type | Condition |
---|---|
NullPointerException | The pointer is zero. |
GetUnaligned(nuint)
Gets the value stored in the memory at the specified position, assuming that this pointer is unaligned.
Declaration
[CLSCompliant(false)]
public T GetUnaligned(nuint index)
Parameters
Type | Name | Description |
---|---|---|
nuint | index | The index of the element. |
Returns
Type | Description |
---|---|
T | The value stored in the memory at the specified position. |
Exceptions
Type | Condition |
---|---|
NullPointerException | The pointer is zero. |
Pin(int)
Pins a block of memory.
Declaration
public MemoryHandle Pin(int elementIndex)
Parameters
Type | Name | Description |
---|---|---|
int | elementIndex | The offset to the element within the memory buffer to which the returned MemoryHandle points. |
Returns
Type | Description |
---|---|
MemoryHandle | A handle to the block of memory. |
ReadFrom(Stream, long)
Copies bytes from the given stream to the memory location identified by this pointer.
Declaration
public long ReadFrom(Stream source, long count)
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
long | count | The number of elements of type |
Returns
Type | Description |
---|---|
long | The actual number of copied elements. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is zero. |
ArgumentException | The stream is not readable. |
ArgumentOutOfRangeException |
|
ReadFromAsync(Stream, long, CancellationToken)
Copies bytes from the given stream to the memory location identified by this pointer asynchronously.
Declaration
public ValueTask<long> ReadFromAsync(Stream source, long count, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
long | count | The number of elements of type |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<long> | The actual number of copied elements. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is zero. |
ArgumentException | The stream is not readable. |
ArgumentOutOfRangeException |
|
OperationCanceledException | The operation has been canceled. |
SetUnaligned(T)
Sets the value stored in the memory identified by this pointer, assuming that this pointer is unaligned.
Declaration
public void SetUnaligned(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be stored in the memory. |
Exceptions
Type | Condition |
---|---|
NullPointerException | The pointer is 0. |
SetUnaligned(T, nuint)
Sets the value at the specified position in the memory, assuming that this pointer is unaligned.
Declaration
[CLSCompliant(false)]
public void SetUnaligned(T value, nuint index)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be stored in the memory. |
nuint | index | The index of the element to modify. |
Exceptions
Type | Condition |
---|---|
NullPointerException | The pointer is 0. |
Swap(Pointer<T>)
Swaps values between this memory location and the given memory location.
Declaration
public void Swap(Pointer<T> other)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | other | The other memory location. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is zero. |
ArgumentNullException |
|
ToArray(int)
Copies the block of memory referenced by this pointer into managed heap as a pinned array.
Declaration
public T[] ToArray(int length)
Parameters
Type | Name | Description |
---|---|---|
int | length | The length of the memory block to be copied. |
Returns
Type | Description |
---|---|
T[] | The array containing elements from the memory block referenced by this pointer. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ToByteArray(int)
Copies the block of memory referenced by this pointer into managed heap as array of bytes.
Declaration
public byte[] ToByteArray(int length)
Parameters
Type | Name | Description |
---|---|---|
int | length | Number of elements to copy. |
Returns
Type | Description |
---|---|
byte[] | A copy of memory block in the form of byte array. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ToMemoryOwner(int)
Converts this pointer the memory owner.
Declaration
public IMemoryOwner<T> ToMemoryOwner(int length)
Parameters
Type | Name | Description |
---|---|---|
int | length | The number of elements in the memory. |
Returns
Type | Description |
---|---|
IMemoryOwner<T> | The instance of memory owner. |
ToSpan(int)
Converts this pointer into Span<T>.
Declaration
public Span<T> ToSpan(int length)
Parameters
Type | Name | Description |
---|---|---|
int | length | The number of elements located in the unmanaged memory identified by this pointer. |
Returns
Type | Description |
---|---|
Span<T> | Span<T> representing elements in the unmanaged memory. |
ToString()
Returns hexadecimal address represented by this pointer.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The hexadecimal value of this pointer. |
Overrides
| Edit this page View SourceWriteTo(Stream, long)
Copies bytes from the memory location identified by this pointer to the stream.
Declaration
[CLSCompliant(false)]
public void WriteTo(Stream destination, long count)
Parameters
Type | Name | Description |
---|---|---|
Stream | destination | The destination stream. |
long | count | The number of elements of type |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
ArgumentException | The stream is not writable. |
ArgumentOutOfRangeException |
|
WriteToAsync(Stream, long, CancellationToken)
Copies bytes from the memory location identified by this pointer to the stream asynchronously.
Declaration
public ValueTask WriteToAsync(Stream destination, long count, CancellationToken token = default)
Parameters
Type | Name | Description |
---|---|---|
Stream | destination | The destination stream. |
long | count | The number of elements of type |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask | The task instance representing asynchronous state of the copying process. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
ArgumentOutOfRangeException |
|
ArgumentException | The stream is not writable. |
OperationCanceledException | The operation has been canceled. |
Operators
| Edit this page View Sourceoperator +(Pointer<T>, int)
Adds an offset to the value of a pointer.
Declaration
public static Pointer<T> operator +(Pointer<T> pointer, int offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
int | offset | The offset to add. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator +(Pointer<T>, long)
Adds an offset to the value of a pointer.
Declaration
public static Pointer<T> operator +(Pointer<T> pointer, long offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
long | offset | The offset to add. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator +(Pointer<T>, nint)
Adds an offset to the value of a pointer.
Declaration
public static Pointer<T> operator +(Pointer<T> pointer, nint offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
nint | offset | The offset to add. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator +(Pointer<T>, nuint)
Adds an offset to the value of a pointer.
Declaration
[CLSCompliant(false)]
public static Pointer<T> operator +(Pointer<T> pointer, nuint offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
nuint | offset | The offset to add. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator checked +(Pointer<T>, int)
Adds an offset to the value of a pointer.
Declaration
public static Pointer<T> operator checked +(Pointer<T> pointer, int offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
int | offset | The offset to add. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator checked +(Pointer<T>, long)
Adds an offset to the value of a pointer.
Declaration
public static Pointer<T> operator checked +(Pointer<T> pointer, long offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
long | offset | The offset to add. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator checked +(Pointer<T>, nint)
Adds an offset to the value of a pointer.
Declaration
public static Pointer<T> operator checked +(Pointer<T> pointer, nint offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
nint | offset | The offset to add. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator checked --(Pointer<T>)
Decrements this pointer by 1 element of type T
.
Declaration
public static Pointer<T> operator checked --(Pointer<T> pointer)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
operator checked ++(Pointer<T>)
Increments this pointer by 1 element of type T
.
Declaration
public static Pointer<T> operator checked ++(Pointer<T> pointer)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
operator checked -(Pointer<T>, int)
Subtracts an offset from the value of a pointer.
Declaration
public static Pointer<T> operator checked -(Pointer<T> pointer, int offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
int | offset | The offset to subtract. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator checked -(Pointer<T>, long)
Subtracts an offset from the value of a pointer.
Declaration
public static Pointer<T> operator checked -(Pointer<T> pointer, long offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
long | offset | The offset to subtract. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator checked -(Pointer<T>, nint)
Subtracts an offset from the value of a pointer.
Declaration
public static Pointer<T> operator checked -(Pointer<T> pointer, nint offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
nint | offset | The offset to subtract. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator checked -(Pointer<T>, nuint)
Subtracts an offset from the value of a pointer.
Declaration
[CLSCompliant(false)]
public static Pointer<T> operator checked -(Pointer<T> pointer, nuint offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
nuint | offset | The offset to subtract. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator --(Pointer<T>)
Decrements this pointer by 1 element of type T
.
Declaration
public static Pointer<T> operator --(Pointer<T> pointer)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
operator ==(Pointer<T>, Pointer<T>)
Indicates that the first pointer represents the same memory location as the second pointer.
Declaration
public static bool operator ==(Pointer<T> first, Pointer<T> second)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | first | The first pointer to be compared. |
Pointer<T> | second | The second pointer to be compared. |
Returns
Type | Description |
---|---|
bool | true, if the first pointer represents the same memory location as the second pointer; otherwise, false. |
explicit operator Pointer<T>(in MemoryHandle)
Obtains pointer to the memory represented by given memory handle.
Declaration
public static explicit operator Pointer<T>(in MemoryHandle handle)
Parameters
Type | Name | Description |
---|---|---|
MemoryHandle | handle | The memory handle. |
Returns
Type | Description |
---|---|
Pointer<T> |
operator false(Pointer<T>)
Checks whether this pointer is zero.
Declaration
public static bool operator false(Pointer<T> ptr)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | ptr | The pointer to check. |
Returns
Type | Description |
---|---|
bool |
operator >(Pointer<T>, Pointer<T>)
Determines whether the address of the first pointer is greater than the address of the second pointer.
Declaration
public static bool operator >(Pointer<T> first, Pointer<T> second)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | first | The first pointer to compare. |
Pointer<T> | second | The second pointer to compare. |
Returns
Type | Description |
---|---|
bool |
operator >=(Pointer<T>, Pointer<T>)
Determines whether the address of the first pointer is greater than or equal to the address of the second pointer.
Declaration
public static bool operator >=(Pointer<T> first, Pointer<T> second)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | first | The first pointer to compare. |
Pointer<T> | second | The second pointer to compare. |
Returns
Type | Description |
---|---|
bool | true if |
implicit operator nint(Pointer<T>)
Obtains pointer value (address) as nint.
Declaration
public static implicit operator nint(Pointer<T> ptr)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | ptr | The pointer to be converted. |
Returns
Type | Description |
---|---|
nint |
implicit operator nuint(Pointer<T>)
Obtains pointer value (address) as nuint.
Declaration
[CLSCompliant(false)]
public static implicit operator nuint(Pointer<T> ptr)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | ptr | The pointer to be converted. |
Returns
Type | Description |
---|---|
nuint |
implicit operator T*(Pointer<T>)
Converts CLS-compliant pointer into its non CLS-compliant representation.
Declaration
[CLSCompliant(false)]
public static implicit operator T*(Pointer<T> ptr)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | ptr | The pointer value. |
Returns
Type | Description |
---|---|
T* |
implicit operator Pointer<T>(T*)
Converts non CLS-compliant pointer into its CLS-compliant representation.
Declaration
[CLSCompliant(false)]
public static implicit operator Pointer<T>(T* value)
Parameters
Type | Name | Description |
---|---|---|
T* | value | The pointer value. |
Returns
Type | Description |
---|---|
Pointer<T> |
operator ++(Pointer<T>)
Increments this pointer by 1 element of type T
.
Declaration
public static Pointer<T> operator ++(Pointer<T> pointer)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the addition of offset to pointer. |
operator !=(Pointer<T>, Pointer<T>)
Indicates that the first pointer represents the different memory location as the second pointer.
Declaration
public static bool operator !=(Pointer<T> first, Pointer<T> second)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | first | The first pointer to be compared. |
Pointer<T> | second | The second pointer to be compared. |
Returns
Type | Description |
---|---|
bool | true, if the first pointer represents the different memory location as the second pointer; otherwise, false. |
operator <(Pointer<T>, Pointer<T>)
Determines whether the address of the first pointer is less than the address of the second pointer.
Declaration
public static bool operator <(Pointer<T> first, Pointer<T> second)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | first | The first pointer to compare. |
Pointer<T> | second | The second pointer to compare. |
Returns
Type | Description |
---|---|
bool |
operator <=(Pointer<T>, Pointer<T>)
Determines whether the address of the first pointer is less than or equal to the address of the second pointer.
Declaration
public static bool operator <=(Pointer<T> first, Pointer<T> second)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | first | The first pointer to compare. |
Pointer<T> | second | The second pointer to compare. |
Returns
Type | Description |
---|---|
bool | true if |
operator -(Pointer<T>, int)
Subtracts an offset from the value of a pointer.
Declaration
public static Pointer<T> operator -(Pointer<T> pointer, int offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
int | offset | The offset to subtract. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator -(Pointer<T>, long)
Subtracts an offset from the value of a pointer.
Declaration
public static Pointer<T> operator -(Pointer<T> pointer, long offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
long | offset | The offset to subtract. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator -(Pointer<T>, nint)
Subtracts an offset from the value of a pointer.
Declaration
public static Pointer<T> operator -(Pointer<T> pointer, nint offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
nint | offset | The offset to subtract. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator -(Pointer<T>, nuint)
Subtracts an offset from the value of a pointer.
Declaration
[CLSCompliant(false)]
public static Pointer<T> operator -(Pointer<T> pointer, nuint offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
nuint | offset | The offset to subtract. |
Returns
Type | Description |
---|---|
Pointer<T> | A new pointer that reflects the subtraction of offset from pointer. |
Remarks
The offset specifies number of elements of type T
, not bytes.
operator true(Pointer<T>)
Checks whether this pointer is not zero.
Declaration
public static bool operator true(Pointer<T> ptr)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | ptr | The pointer to check. |
Returns
Type | Description |
---|---|
bool |