Table of Contents

Struct TextSpan

Namespace
MuLang.Core.Text
Assembly
MuLang.Core.dll

Represents a contiguous range of source text.

public readonly struct TextSpan : IEquatable<TextSpan>
Implements
Inherited Members

Constructors

TextSpan(int, int)

Initializes a new instance of the TextSpan struct.

public TextSpan(int start, int length)

Parameters

start int

The start offset.

length int

The span length.

Exceptions

ArgumentOutOfRangeException

Thrown when start or length is negative.

Properties

End

Gets the exclusive end offset.

public int End { get; }

Property Value

int

Exceptions

OverflowException

Thrown when the end offset exceeds MaxValue.

Length

Gets the span length.

public int Length { get; }

Property Value

int

Start

Gets the inclusive start offset.

public int Start { get; }

Property Value

int

Methods

Contains(int)

Determines whether an offset is within the span.

public bool Contains(int offset)

Parameters

offset int

The Unicode scalar offset.

Returns

bool

true if the offset is within the span; otherwise, false.

Exceptions

OverflowException

Thrown when the span end exceeds MaxValue.

Equals(TextSpan)

public bool Equals(TextSpan other)

Parameters

other TextSpan

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

FromBounds(int, int)

Creates a span from inclusive start and exclusive end offsets.

public static TextSpan FromBounds(int start, int end)

Parameters

start int

The start offset.

end int

The exclusive end offset.

Returns

TextSpan

The span between the specified bounds.

Exceptions

ArgumentOutOfRangeException

Thrown when start is negative or end precedes it.

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(TextSpan, TextSpan)

public static bool operator ==(TextSpan left, TextSpan right)

Parameters

left TextSpan
right TextSpan

Returns

bool

operator !=(TextSpan, TextSpan)

public static bool operator !=(TextSpan left, TextSpan right)

Parameters

left TextSpan
right TextSpan

Returns

bool