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 struct Pointer<T> : IEquatable<Pointer<T>>, IStrongBox, IConvertible<IntPtr>, IConvertible<UIntPtr>, IPinnable where T : struct
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
| Improve this Doc View SourcePointer(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. |
Pointer(IntPtr)
Constructs pointer from IntPtr value.
Declaration
public Pointer(IntPtr ptr)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | ptr | The pointer value. |
Pointer(UIntPtr)
Constructs pointer from UIntPtr value.
Declaration
[CLSCompliant(false)]
public Pointer(UIntPtr ptr)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | ptr | The pointer value. |
Properties
| Improve this Doc View SourceAddress
Gets pointer address.
Declaration
public IntPtr Address { get; }
Property Value
Type | Description |
---|---|
IntPtr |
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 |
---|---|
Boolean |
IsNull
Indicates that this pointer is null.
Declaration
public bool IsNull { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int64]
Gets or sets pointer value at the specified position in the memory.
Declaration
public T this[long index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int64 | 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 T Value { get; }
Property Value
Type | Description |
---|---|
T | The reference to the memory location. |
Exceptions
Type | Condition |
---|---|
NullPointerException | The pointer is 0. |
Methods
| Improve this Doc View SourceAs<TOther>()
Reinterprets pointer type.
Declaration
public Pointer<TOther> As<TOther>()
where TOther : struct
Returns
Type | Description |
---|---|
Pointer<TOther> | Reinterpreted pointer type. |
Type Parameters
Name | Description |
---|---|
TOther | A new pointer type. |
AsStream(Int64, 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.Read | FileAccess.ReadWrite | FileAccess.Write)
Parameters
Type | Name | Description |
---|---|---|
Int64 | 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.
BitwiseCompare(Pointer<T>, Int64)
Bitwise comparison of two memory blocks.
Declaration
public int BitwiseCompare(Pointer<T> other, long count)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | other | The pointer identifies block of memory to be compared. |
Int64 | count | The number of elements of type |
Returns
Type | Description |
---|---|
Int32 | Comparison result which has the semantics as return type of CompareTo(Object). |
BitwiseEquals(Pointer<T>, Int64)
Computes bitwise equality between two blocks of memory.
Declaration
public bool BitwiseEquals(Pointer<T> other, long count)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | other | The pointer identifies block of memory to be compared. |
Int64 | count | The number of elements of type |
Returns
Type | Description |
---|---|
Boolean | true, if both memory blocks have the same bytes; otherwise, false. |
BitwiseHashCode(Int64, Boolean)
Computes 32-bit hash code for the block of memory identified by this pointer.
Declaration
public int BitwiseHashCode(long count, bool salted = true)
Parameters
Type | Name | Description |
---|---|---|
Int64 | count | The number of elements of type |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | Content hash code. |
BitwiseHashCode(Int64, Int32, Func<Int32, Int32, Int32>, Boolean)
Computes 32-bit hash code for the block of memory identified by this pointer.
Declaration
public int BitwiseHashCode(long count, int hash, Func<int, int, int> hashFunction, bool salted = true)
Parameters
Type | Name | Description |
---|---|---|
Int64 | count | The number of elements of type |
Int32 | hash | Initial value of the hash to be passed into hashing function. |
Func<Int32, Int32, Int32> | hashFunction | The custom hash function. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | Content hash code. |
BitwiseHashCode(Int64, Int32, ValueFunc<Int32, Int32, Int32>, Boolean)
Computes 32-bit hash code for the block of memory identified by this pointer.
Declaration
public int BitwiseHashCode(long count, int hash, in ValueFunc<int, int, int> hashFunction, bool salted = true)
Parameters
Type | Name | Description |
---|---|---|
Int64 | count | The number of elements of type |
Int32 | hash | Initial value of the hash to be passed into hashing function. |
ValueFunc<Int32, Int32, Int32> | hashFunction | The custom hash function. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int32 | Content hash code. |
BitwiseHashCode64(Int64, Boolean)
Computes 64-bit hash code for the block of memory identified by this pointer.
Declaration
public long BitwiseHashCode64(long count, bool salted = true)
Parameters
Type | Name | Description |
---|---|---|
Int64 | count | The number of elements of type |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | Content hash code. |
BitwiseHashCode64(Int64, Int64, Func<Int64, Int64, Int64>, Boolean)
Computes 64-bit hash code for the block of memory identified by this pointer.
Declaration
public long BitwiseHashCode64(long count, long hash, Func<long, long, long> hashFunction, bool salted = true)
Parameters
Type | Name | Description |
---|---|---|
Int64 | count | The number of elements of type |
Int64 | hash | Initial value of the hash to be passed into hashing function. |
Func<Int64, Int64, Int64> | hashFunction | The custom hash function. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | Content hash code. |
BitwiseHashCode64(Int64, Int64, ValueFunc<Int64, Int64, Int64>, Boolean)
Computes 64-bit hash code for the block of memory identified by this pointer.
Declaration
public long BitwiseHashCode64(long count, long hash, in ValueFunc<long, long, long> hashFunction, bool salted = true)
Parameters
Type | Name | Description |
---|---|---|
Int64 | count | The number of elements of type |
Int64 | hash | Initial value of the hash to be passed into hashing function. |
ValueFunc<Int64, Int64, Int64> | hashFunction | The custom hash function. |
Boolean | salted | true to include randomized salt data into hashing; false to use data from memory only. |
Returns
Type | Description |
---|---|
Int64 | Content hash code. |
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(Int64)
Fill memory with zero bytes.
Declaration
public void Clear(long count)
Parameters
Type | Name | Description |
---|---|---|
Int64 | count | Number of elements in the unmanaged array. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
ArgumentOutOfRangeException |
|
Equals(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 |
---|---|
Boolean | true, if the value stored in the memory identified by this pointer is equal to the given value; otherwise, false. |
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 |
---|---|
Boolean | true, if this pointer represents the same memory location as other pointer; otherwise, false. |
Overrides
| Improve this Doc View SourceEquals<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 : struct
Parameters
Type | Name | Description |
---|---|---|
Pointer<TOther> | other | The pointer to be compared. |
Returns
Type | Description |
---|---|
Boolean | 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, Int64)
Fills the elements of the array with a specified value.
Declaration
public void Fill(T value, long count)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to assign to each element of the array. |
Int64 | count | The length of the array. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is zero. |
ArgumentOutOfRangeException |
|
Get()
Gets the value stored in the memory identified by this pointer.
Declaration
public T Get()
Returns
Type | Description |
---|---|
T | The value stored in the memory. |
Exceptions
Type | Condition |
---|---|
NullPointerException | The pointer is 0. |
Get(Int64)
Gets the value stored in the memory at the specified position.
Declaration
public T Get(long index)
Parameters
Type | Name | Description |
---|---|---|
Int64 | 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 0. |
GetBoxedPointer()
Gets boxed pointer.
Declaration
[CLSCompliant(false)]
public object GetBoxedPointer()
Returns
Type | Description |
---|---|
Object | The boxed pointer. |
See Also
| Improve this Doc View SourceGetEnumerator(Int64)
Gets enumerator over raw memory.
Declaration
public Pointer<T>.Enumerator GetEnumerator(long length)
Parameters
Type | Name | Description |
---|---|---|
Int64 | length | A number of elements to iterate. |
Returns
Type | Description |
---|---|
Pointer.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 |
---|---|
Int32 | The hash code of this pointer. |
Overrides
| Improve this Doc 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 |
---|---|
Int32 | The hash code of the value stored in the memory identified by this pointer. |
ReadFrom(T[], Int64, Int64)
Copies elements from the specified array into the memory block identified by this pointer.
Declaration
public long ReadFrom(T[] source, long offset, long count)
Parameters
Type | Name | Description |
---|---|---|
T[] | source | The source array. |
Int64 | offset | The position in the source array from which copying begins. |
Int64 | count | The number of elements of type |
Returns
Type | Description |
---|---|
Int64 | Actual number of copied elements. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
ArgumentOutOfRangeException |
|
ReadFrom(Stream, Int64)
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. |
Int64 | count | The number of elements of type |
Returns
Type | Description |
---|---|
Int64 | The actual number of copied elements. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is zero. |
ArgumentException | The stream is not readable. |
ArgumentOutOfRangeException |
|
ReadFromAsync(Stream, Int64, 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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | source | The source stream. |
Int64 | count | The number of elements of type |
CancellationToken | token | The token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
ValueTask<Int64> | 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. |
Set(T)
Sets the value stored in the memory identified by this pointer.
Declaration
public void Set(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be stored in the memory. |
Exceptions
Type | Condition |
---|---|
NullPointerException | The pointer is 0. |
Set(T, Int64)
Sets the value at the specified position in the memory.
Declaration
public void Set(T value, long index)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be stored in the memory. |
Int64 | 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(Int64)
Copies the block of memory referenced by this pointer into managed heap as array.
Declaration
public T[] ToArray(long length)
Parameters
Type | Name | Description |
---|---|---|
Int64 | 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. |
ToByteArray(Int64)
Copies the block of memory referenced by this pointer into managed heap as array of bytes.
Declaration
public byte[] ToByteArray(long length)
Parameters
Type | Name | Description |
---|---|---|
Int64 | length | Number of elements to copy. |
Returns
Type | Description |
---|---|
Byte[] | A copy of memory block in the form of byte array. |
ToMemoryOwner(Int32)
Converts this pointer the memory owner.
Declaration
public IMemoryOwner<T> ToMemoryOwner(int length)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | The number of elements in the memory. |
Returns
Type | Description |
---|---|
IMemoryOwner<T> | The instance of memory owner. |
ToSpan(Int32)
Converts this pointer into Span<T>.
Declaration
public Span<T> ToSpan(int length)
Parameters
Type | Name | Description |
---|---|---|
Int32 | 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
| Improve this Doc View SourceWriteTo(T[], Int64, Int64)
Copies elements from the memory location identified by this pointer to managed array.
Declaration
public long WriteTo(T[] destination, long offset, long count)
Parameters
Type | Name | Description |
---|---|---|
T[] | destination | The array to be modified. |
Int64 | offset | The position in the destination array from which copying begins. |
Int64 | count | The number of elements of type |
Returns
Type | Description |
---|---|
Int64 | Actual number of copied elements. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
ArgumentOutOfRangeException |
|
WriteTo(Pointer<T>, Int64)
Copies block of memory from the source address to the destination address.
Declaration
public void WriteTo(Pointer<T> destination, long count)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | destination | Destination address. |
Int64 | count | The number of elements to be copied. |
Exceptions
Type | Condition |
---|---|
NullPointerException | This pointer is equal to zero. |
ArgumentNullException | Destination pointer is zero. |
WriteTo(Stream, Int64)
Copies bytes from the memory location identified by this pointer to the stream.
Declaration
public void WriteTo(Stream destination, long count)
Parameters
Type | Name | Description |
---|---|---|
Stream | destination | The destination stream. |
Int64 | 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, Int64, 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(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Stream | destination | The destination stream. |
Int64 | 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
| Improve this Doc View SourceAddition(Pointer<T>, Int32)
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. |
Int32 | 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.
Addition(Pointer<T>, Int64)
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. |
Int64 | 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.
Addition(Pointer<T>, IntPtr)
Adds an offset to the value of a pointer.
Declaration
public static Pointer<T> operator +(Pointer<T> pointer, IntPtr offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
IntPtr | 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.
Addition(Pointer<T>, UInt64)
Adds an offset to the value of a pointer.
Declaration
[CLSCompliant(false)]
public static Pointer<T> operator +(Pointer<T> pointer, ulong offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to add the offset to. |
UInt64 | 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.
Decrement(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. |
Equality(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 |
---|---|
Boolean | true, if the first pointer represents the same memory location as the second pointer; otherwise, false. |
Explicit(MemoryHandle to Pointer<T>)
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> |
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 |
---|---|
Boolean | true, if this pointer is zero; otherwise, false. |
Implicit(T* to Pointer<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> |
Implicit(Pointer<T> to 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(Pointer<T> to IntPtr)
Obtains pointer value (address) as IntPtr.
Declaration
public static implicit operator IntPtr(Pointer<T> ptr)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | ptr | The pointer to be converted. |
Returns
Type | Description |
---|---|
IntPtr |
Implicit(Pointer<T> to UIntPtr)
Obtains pointer value (address) as UIntPtr.
Declaration
[CLSCompliant(false)]
public static implicit operator UIntPtr(Pointer<T> ptr)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | ptr | The pointer to be converted. |
Returns
Type | Description |
---|---|
UIntPtr |
Increment(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. |
Inequality(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 |
---|---|
Boolean | true, if the first pointer represents the different memory location as the second pointer; otherwise, false. |
Subtraction(Pointer<T>, Int32)
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. |
Int32 | 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.
Subtraction(Pointer<T>, Int64)
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. |
Int64 | 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.
Subtraction(Pointer<T>, IntPtr)
Subtracts an offset from the value of a pointer.
Declaration
public static Pointer<T> operator -(Pointer<T> pointer, IntPtr offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
IntPtr | 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.
Subtraction(Pointer<T>, UInt64)
Subtracts an offset from the value of a pointer.
Declaration
[CLSCompliant(false)]
public static Pointer<T> operator -(Pointer<T> pointer, ulong offset)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | pointer | The pointer to subtract the offset from. |
UInt64 | 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.
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 |
---|---|
Boolean | true, if this pointer is not zero; otherwise, false. |
Explicit Interface Implementations
| Improve this Doc View SourceIPinnable.Pin(Int32)
Declaration
MemoryHandle IPinnable.Pin(int elementIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | elementIndex |
Returns
Type | Description |
---|---|
MemoryHandle |
IPinnable.Unpin()
Declaration
void IPinnable.Unpin()
IEquatable<Pointer<T>>.Equals(Pointer<T>)
Declaration
bool IEquatable<Pointer<T>>.Equals(Pointer<T> other)
Parameters
Type | Name | Description |
---|---|---|
Pointer<T> | other |
Returns
Type | Description |
---|---|
Boolean |
IStrongBox.Value
Declaration
object IStrongBox.Value { get; set; }
Returns
Type | Description |
---|---|
Object |