Struct TextSpan
Represents a contiguous range of characters in a markup text.
public readonly record struct TextSpan : IEquatable<TextSpan>
- Implements
- Inherited Members
- Extension Methods
Constructors
TextSpan(int, int)
Initializes a new instance of the TextSpan struct.
public TextSpan(int start, int length)
Parameters
startintThe offset of the first character in the span.
lengthintThe number of characters in the span.
Exceptions
- ArgumentOutOfRangeException
startorlengthis negative.
Properties
End
Gets the offset just past the last character in the span.
public int End { get; }
Property Value
Length
Gets the number of characters in the span.
public int Length { get; }
Property Value
Start
Gets the offset of the first character in the span.
public int Start { get; }
Property Value
Methods
FromBounds(int, int)
Creates a span from its start and end offsets.
public static TextSpan FromBounds(int start, int end)
Parameters
startintThe offset of the first character in the span.
endintThe offset just past the last character in the span.
Returns
- TextSpan
The span covering
[start, end).
Exceptions
- ArgumentOutOfRangeException
endis less thanstart.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.