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
TextPositionThe start of the range.
end
TextPositionThe end of the range.
Properties
End
Gets the end position of the range.
public TextPosition End { get; }
Property Value
Start
Gets the start position of the range.
public TextPosition Start { get; }
Property Value
Methods
CompareTo(TextRange)
Compares the current range with another range.
public int CompareTo(TextRange other)
Parameters
other
TextRangeThe 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
TextRangeAn 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
objectThe 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
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
Returns
- bool
True if the end position of the first operand is less than the start position of the second operand.