Skip to content

IdSpan Methods

Primitive type for identities, representing a sequence of bytes.

AsSpan

View source
public ReadOnlySpan<byte> AsSpan()
Returns a span representation of this instance.

Returns

A span representation of this instance.

CompareTo(IdSpan)

View source
public int CompareTo(IdSpan other)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

Parameters

otherIdSpan
An object to compare with this instance.

Returns

A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

Create(string)

static
View source
public static IdSpan Create(string id)
Creates a new IdSpan instance from the provided value.

Parameters

idstring

Returns

A new IdSpan corresponding to the provided id.

Equals(IdSpan)

View source
public bool Equals(IdSpan obj)
Indicates whether the current object is equal to another object of the same type.

Parameters

objIdSpan
An object to compare with this object.

Returns

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

override
View source
public override bool Equals(object? obj)
Indicates whether this instance and a specified object are equal.

Parameters

objobject?
The object to compare with the current instance.

Returns

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode

override
View source
public override int GetHashCode()
Returns the hash code for this instance.

Returns

A 32-bit signed integer that is the hash code for this instance.

GetObjectData(SerializationInfo, StreamingContext)

View source
public void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a System.Runtime.Serialization.SerializationInfo with the data needed to serialize the target object.

Parameters

infoSerializationInfo
The System.Runtime.Serialization.SerializationInfo to populate with data.
contextStreamingContext
The destination (see System.Runtime.Serialization.StreamingContext) for this serialization.

Exceptions

System.Security.SecurityException
The caller does not have the required permission.

ToString

override
View source
public override string ToString()
Returns a string representation of this instance, decoding the value as UTF8.

Returns

A string representation fo this instance.

UnsafeCreate(byte[]?, int)

static
View source
public static IdSpan UnsafeCreate(byte[]? value, int hashCode)
Creates an instance, specifying both the hash code and the value.

Parameters

valuebyte[]?
The underlying value.
hashCodeint
The hash of the underlying value.

Returns

An IdSpan instance.

UnsafeGetArray(IdSpan)

static
View source
public static byte[]? UnsafeGetArray(IdSpan id)
Gets the underlying array from this instance.

Parameters

idIdSpan
The id span.

Returns

The underlying array from this instance.

operator ==(IdSpan, IdSpan)

static
View source
public static bool operator ==(IdSpan left, IdSpan right)
Compares the provided operands for equality.

Parameters

leftIdSpan
The left operand.
rightIdSpan
The right operand.

Returns

true if the provided values are equal, otherwise false.

operator !=(IdSpan, IdSpan)

static
View source
public static bool operator !=(IdSpan left, IdSpan right)
Compares the provided operands for inequality.

Parameters

leftIdSpan
The left operand.
rightIdSpan
The right operand.

Returns

true if the provided values are not equal, otherwise false.