Struct TextSpan
- Namespace
- TextEdit.Core
- Assembly
- TextEdit.Core.dll
A half-open range of UTF-16 code units.
public readonly record struct TextSpan : IEquatable<TextSpan>
- Implements
- Inherited Members
Constructors
TextSpan(int, int)
Creates a nonnegative, non-overflowing range.
public TextSpan(int start, int length)
Parameters
Properties
Empty
Gets an empty range at the start of a document.
public static TextSpan Empty { get; }
Property Value
End
Gets the exclusive end.
public int End { get; }
Property Value
IsEmpty
Gets whether the range is a caret position.
public bool IsEmpty { get; }
Property Value
Length
Gets the UTF-16 length.
public int Length { get; }
Property Value
Start
Gets the inclusive start.
public int Start { get; }
Property Value
Methods
Clamp(int)
Clamps both endpoints to a nonnegative text length.
public TextSpan Clamp(int textLength)
Parameters
textLengthint
Returns
ToRange()
Gets the equivalent bounded System.Range.
public Range ToRange()
Returns
Validate(int, string?)
Rejects a range outside the specified text length.
public void Validate(int textLength, string? parameterName = null)