Table of Contents

Struct TextRange

Namespace
AngleSharp.Text
Assembly
AngleSharp.dll

The positional range in the source code.

public readonly struct TextRange : IEquatable<TextRange>, IComparable<TextRange>
Implements
Inherited Members
Extension Methods

Constructors

TextRange(TextPosition, TextPosition)

Creates a new text range.

public TextRange(TextPosition start, TextPosition end)

Parameters

start TextPosition

The start of the range.

end TextPosition

The end of the range.

Properties

End

Gets the end position of the range.

public TextPosition End { get; }

Property Value

TextPosition

Start

Gets the start position of the range.

public TextPosition Start { get; }

Property Value

TextPosition

Methods

CompareTo(TextRange)

Compares the current range with another range.

public int CompareTo(TextRange other)

Parameters

other TextRange

The range to compare to.

Returns

int

A mathematical representation of the relation (1 = greater, -1 = less, 0 = equal).

Equals(TextRange)

Indicates whether the current range is equal to the given range.

public bool Equals(TextRange other)

Parameters

other TextRange

An object to compare with this object.

Returns

bool

True if the given range has the same start and end position, otherwise false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

True if the given object is a text position with the same values, otherwise false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

An integer that is the hash code for this instance.

ToString()

Returns a string representation of the range in the text.

public override string ToString()

Returns

string

A string that contains the start and end positions.

Operators

operator >(TextRange, TextRange)

Compares the two ranges by their positions in the text source.

public static bool operator >(TextRange a, TextRange b)

Parameters

a TextRange

The first operand.

b TextRange

The second operand.

Returns

bool

True if the start position of the first operand is greater than the end position of the second operand.

operator <(TextRange, TextRange)

Compares the two ranges by their positions in the text source.

public static bool operator <(TextRange a, TextRange b)

Parameters

a TextRange

The first operand.

b TextRange

The second operand.

Returns

bool

True if the end position of the first operand is less than the start position of the second operand.