Table of Contents

Struct StringSpan

Namespace
SampSharp.Entities.SAMP.Commands
Assembly
SampSharp.OpenMp.Entities.Commands.dll

Represents a span of characters within a string.

public readonly struct StringSpan : IEquatable<string>, IEquatable<StringSpan>
Implements
Inherited Members

Fields

Empty

Gets an empty StringSpan.

public static readonly StringSpan Empty

Field Value

StringSpan

Properties

this[int]

Gets the character at the specified index within the span.

public char this[int index] { get; }

Parameters

index int

The index of the character.

Property Value

char

The character at the specified index.

Length

Gets the length of the span.

public int Length { get; }

Property Value

int

String

Gets the underlying string.

public string String { get; }

Property Value

string

Methods

AsSpan()

Returns a read-only span of characters that represents the current span.

public ReadOnlySpan<char> AsSpan()

Returns

ReadOnlySpan<char>

A read-only span of characters that represents the current span.

Equals(StringSpan)

Determines whether the current span is equal to the specified StringSpan.

public bool Equals(StringSpan other)

Parameters

other StringSpan

The StringSpan to compare.

Returns

bool

true if the current span is equal to the specified StringSpan; otherwise, false.

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Equals(ReadOnlySpan<char>)

Determines whether the current span is equal to the specified read-only span of characters.

public bool Equals(ReadOnlySpan<char> other)

Parameters

other ReadOnlySpan<char>

The read-only span of characters to compare.

Returns

bool

true if the current span is equal to the specified read-only span of characters; otherwise, false.

Equals(string?)

Determines whether the current span is equal to the specified string.

public bool Equals(string? other)

Parameters

other string

The string to compare.

Returns

bool

true if the current span is equal to the specified string; otherwise, false.

For(string)

Creates a StringSpan that represents the entire string.

public static StringSpan For(string @string)

Parameters

string string

The underlying string.

Returns

StringSpan

A StringSpan that represents the entire string.

GetHashCode()

public override int GetHashCode()

Returns

int

GetOffsetAndLength()

Gets the offset of the span from the start of the source text and the length of the span.

public (int offset, int length) GetOffsetAndLength()

Returns

(int offset, int length)

The offset and length of the span.

Skip(int)

Creates a new StringSpan that skips the specified number of characters from the start.

public StringSpan Skip(int count)

Parameters

count int

The number of characters to skip.

Returns

StringSpan

A new StringSpan that skips the specified number of characters from the start.

Exceptions

ArgumentOutOfRangeException

Thrown when the count is negative or greater than the current span length.

Take(int)

Creates a new StringSpan that represents a portion of the current span.

public StringSpan Take(int length)

Parameters

length int

The length of the new span.

Returns

StringSpan

A new StringSpan that represents a portion of the current span.

Exceptions

ArgumentOutOfRangeException

Thrown when the length is negative or greater than the current span length.

ToString()

public override string ToString()

Returns

string

TrimEnd()

Creates a new StringSpan with trailing whitespace removed.

public StringSpan TrimEnd()

Returns

StringSpan

A new StringSpan with trailing whitespace removed.

TrimStart()

Creates a new StringSpan with leading whitespace removed.

public StringSpan TrimStart()

Returns

StringSpan

A new StringSpan with leading whitespace removed.

Operators

operator ==(StringSpan, StringSpan)

Determines whether two StringSpan instances are equal.

public static bool operator ==(StringSpan span1, StringSpan span2)

Parameters

span1 StringSpan

The first StringSpan to compare.

span2 StringSpan

The second StringSpan to compare.

Returns

bool

true if the two StringSpan instances are equal; otherwise, false.

operator ==(StringSpan, ReadOnlySpan<char>)

Determines whether a StringSpan instance is equal to a read-only span of characters.

public static bool operator ==(StringSpan span1, ReadOnlySpan<char> span2)

Parameters

span1 StringSpan

The StringSpan to compare.

span2 ReadOnlySpan<char>

The read-only span of characters to compare.

Returns

bool

true if the StringSpan instance is equal to the read-only span of characters; otherwise, false.

operator ==(ReadOnlySpan<char>, StringSpan)

Determines whether a read-only span of characters is equal to a StringSpan instance.

public static bool operator ==(ReadOnlySpan<char> span1, StringSpan span2)

Parameters

span1 ReadOnlySpan<char>

The read-only span of characters to compare.

span2 StringSpan

The StringSpan to compare.

Returns

bool

true if the read-only span of characters is equal to the StringSpan instance; otherwise, false.

implicit operator ReadOnlySpan<char>(StringSpan)

Implicitly converts a StringSpan to a read-only span of characters.

public static implicit operator ReadOnlySpan<char>(StringSpan span)

Parameters

span StringSpan

The StringSpan to convert.

Returns

ReadOnlySpan<char>

A read-only span of characters.

operator !=(StringSpan, StringSpan)

Determines whether two StringSpan instances are not equal.

public static bool operator !=(StringSpan span1, StringSpan span2)

Parameters

span1 StringSpan

The first StringSpan to compare.

span2 StringSpan

The second StringSpan to compare.

Returns

bool

true if the two StringSpan instances are not equal; otherwise, false.

operator !=(StringSpan, ReadOnlySpan<char>)

Determines whether a StringSpan instance is not equal to a read-only span of characters.

public static bool operator !=(StringSpan span1, ReadOnlySpan<char> span2)

Parameters

span1 StringSpan

The StringSpan to compare.

span2 ReadOnlySpan<char>

The read-only span of characters to compare.

Returns

bool

true if the StringSpan instance is not equal to the read-only span of characters; otherwise, false.

operator !=(ReadOnlySpan<char>, StringSpan)

Determines whether a read-only span of characters is not equal to a StringSpan instance.

public static bool operator !=(ReadOnlySpan<char> span1, StringSpan span2)

Parameters

span1 ReadOnlySpan<char>

The read-only span of characters to compare.

span2 StringSpan

The StringSpan to compare.

Returns

bool

true if the read-only span of characters is not equal to the StringSpan instance; otherwise, false.