Struct ReadOnlyNativeMemory
Represents an allocated read-only native memory buffer of unspecified type
public readonly struct ReadOnlyNativeMemory : IEquatable<ReadOnlyNativeMemory>, ISpanFormattable, IFormattable, IEqualityOperators<ReadOnlyNativeMemory, ReadOnlyNativeMemory, bool>
- Implements
- Inherited Members
Properties
Empty
Gets an empty ReadOnlyNativeMemory
public static ReadOnlyNativeMemory Empty { get; }
Property Value
- ReadOnlyNativeMemory
An empty ReadOnlyNativeMemory
IsEmpty
Gets a value indicating whether the allocated memory buffer is empty
public bool IsEmpty { get; }
Property Value
- bool
A value indicating whether the allocated memory buffer is empty
- See Also
IsPinned
Gets a value indicating whether the underlying NativeMemoryManagerBase of this allocated memory buffer is pinned
public bool IsPinned { get; }
Property Value
- bool
A value indicating whether the underlying NativeMemoryManagerBase of this allocated memory buffer is pinned
- See Also
IsValid
Gets a value indicating whether the allocated memory buffer is valid
public bool IsValid { get; }
Property Value
- bool
A value indicating whether the allocated memory buffer is valid
Remarks
A valid ReadOnlyNativeMemory might become invalid after the underlying NativeMemoryManager changed (e.g. by calling TryRealloc(ref NativeMemoryManager?, nuint) on it).
Length
Gets the number of bytes in the allocated memory buffer
public nuint Length { get; }
Property Value
- nuint
The number of bytes in the allocated memory buffer
Pointer
Gets a pointer to the start of the allocated memory buffer
public nint Pointer { get; }
Property Value
- nint
A pointer to the start of the allocated memory buffer
Methods
Equals(ReadOnlyNativeMemory)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(ReadOnlyNativeMemory other)
Parameters
otherReadOnlyNativeMemoryAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Pin()
Pins the underlying NativeMemoryManager
public NativeMemoryPin Pin()
Returns
- NativeMemoryPin
A pin pinning the underlying NativeMemoryManager
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToString(IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(IFormatProvider? formatProvider)
Parameters
formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
ToString(string?)
Formats the value of the current instance using the specified format.
public string ToString(string? format)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.
Returns
- string
The value of the current instance in the specified format.
ToString(string?, IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Tries to format the value of the current instance into the provided span of characters.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)
Parameters
destinationSpan<char>The span in which to write this instance's value formatted as a span of characters.
charsWrittenintWhen this method returns, contains the number of characters that were written in
destination.formatReadOnlySpan<char>A span containing the characters that represent a standard or custom format string that defines the acceptable format for
destination.providerIFormatProviderAn optional object that supplies culture-specific formatting information for
destination.
Returns
Operators
operator ==(ReadOnlyNativeMemory, ReadOnlyNativeMemory)
Compares two values to determine equality.
public static bool operator ==(ReadOnlyNativeMemory left, ReadOnlyNativeMemory right)
Parameters
leftReadOnlyNativeMemoryThe value to compare with
right.rightReadOnlyNativeMemoryThe value to compare with
left.
Returns
operator !=(ReadOnlyNativeMemory, ReadOnlyNativeMemory)
Compares two values to determine inequality.
public static bool operator !=(ReadOnlyNativeMemory left, ReadOnlyNativeMemory right)
Parameters
leftReadOnlyNativeMemoryThe value to compare with
right.rightReadOnlyNativeMemoryThe value to compare with
left.