TextSpan Struct
Represents a contiguous character range in text.
public readonly struct TextSpan : IComparable<TextSpan>, IEquatable<TextSpan>Example
var span = new TextSpan(start: 5, length: 3);
var sameSpan = TextSpan.FromBounds(5, 8);
Assert.Equal(span, sameSpan);
Assert.Equal(8, span.End);Constructors
| Name | Description |
|---|---|
| TextSpan(int, int) |
TextSpan(int, int)
TextSpan.csProperties
| Name | Description |
|---|---|
| End | |
| IsEmpty | Gets a value indicating whether the span is zero-length. |
| Length | |
| Start |
End
TextSpan.csIsEmpty
TextSpan.csLength
TextSpan.csStart
TextSpan.csMethods
| Name | Description |
|---|---|
| CompareTo(TextSpan) | Orders spans by TextSpan.Start, then by TextSpan.Length. |
| Contains(TextSpan) | Determines whether the span contains all of span. |
| Contains(int) | Determines whether the span contains position. The end of the span is exclusive. |
| Equals(TextSpan) | |
| Equals(object?) | |
| FromBounds(int, int) | |
| GetHashCode() | |
| Intersection(TextSpan) | Returns the intersection of the two spans, or null when they do not intersect. Two spans that only touch intersect in an empty span. |
| IntersectsWith(TextSpan) | Determines whether the two spans share at least one character or touch at an endpoint. |
| IntersectsWith(int) | Determines whether position is inside the span or at its end. |
| Overlap(TextSpan) | Returns the overlap of the two spans, or null when they do not overlap. |
| OverlapsWith(TextSpan) | Determines whether the two spans share at least one character. Empty spans never overlap. |
| ToString() |
CompareTo(TextSpan)
TextSpan.csOrders spans by TextSpan.Start, then by TextSpan.Length.
FromBounds(int, int)
TextSpan.csGetHashCode()
TextSpan.csIntersection(TextSpan)
TextSpan.csOverlap(TextSpan)
TextSpan.csOverlapsWith(TextSpan)
TextSpan.csToString()
TextSpan.csOperators
| Name | Description |
|---|---|
| operator ==(TextSpan, TextSpan) | |
| operator >(TextSpan, TextSpan) | |
| operator >=(TextSpan, TextSpan) | |
| operator !=(TextSpan, TextSpan) | |
| operator <(TextSpan, TextSpan) | |
| operator <=(TextSpan, TextSpan) |