Table of Contents

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

start int
length int

Properties

Empty

Gets an empty range at the start of a document.

public static TextSpan Empty { get; }

Property Value

TextSpan

End

Gets the exclusive end.

public int End { get; }

Property Value

int

IsEmpty

Gets whether the range is a caret position.

public bool IsEmpty { get; }

Property Value

bool

Length

Gets the UTF-16 length.

public int Length { get; }

Property Value

int

Start

Gets the inclusive start.

public int Start { get; }

Property Value

int

Methods

Clamp(int)

Clamps both endpoints to a nonnegative text length.

public TextSpan Clamp(int textLength)

Parameters

textLength int

Returns

TextSpan

ToRange()

Gets the equivalent bounded System.Range.

public Range ToRange()

Returns

Range

Validate(int, string?)

Rejects a range outside the specified text length.

public void Validate(int textLength, string? parameterName = null)

Parameters

textLength int
parameterName string