Table of Contents

Class CStringHandle

Namespace
Ubiquity.NET.InteropHelpers
Assembly
Ubiquity.NET.InteropHelpers.dll

Abstract base class for types that represents a native string

public abstract class CStringHandle : SafeHandle, IDisposable, IEquatable<CStringHandle>
Inheritance
CStringHandle
Implements
Inherited Members

Remarks

This base class provides most of the functionality for a string pointer except the disposal/release of the string (if Any). That is left to derived types to provide the specific operation to release the pointer. In particular this provides a simple copy by value marshalling and there is no copy made nor any marshalling to managed code overhead until ToString() is called. In particular, ReadOnlySpan will NOT make a managed copy. The returned span is to the original unmanaged memory.

Constructors

CStringHandle()

Initializes a new instance of the CStringHandle class.

CStringHandle(byte*)

Initializes a new instance of the CStringHandle class.

CStringHandle(nint)

Initializes a new instance of the CStringHandle class.

Properties

IsInvalid

When overridden in a derived class, gets a value indicating whether the handle value is invalid.

ReadOnlySpan

Gets a readonly span for the data in this string

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

Equals(ReadOnlySpan<byte>)

Tests if the span of characters for this string is identical to the provided span

Equals(CStringHandle?)

Indicates whether the current object is equal to another object of the same type.

GetHashCode()

Serves as the default hash function.

GetHashCode(StringComparison)

Returns the hash code for this string using the specified rules.

ToString()

Converts the underlying string pointer into a managed string