Immutable abstract representation of a span of text. For example, in an error diagnostic that reports a location, it could come from a parsed string, text from a tool editor buffer, etc.
public value class TextSpan : IComparable<Microsoft::CodeAnalysis::Text::TextSpan>, IEquatable<Microsoft::CodeAnalysis::Text::TextSpan>
public readonly struct TextSpan : IComparable<Microsoft.CodeAnalysis.Text.TextSpan>, IEquatable<Microsoft.CodeAnalysis.Text.TextSpan>
[System.Runtime.Serialization.DataContract]
public readonly struct TextSpan : IComparable<Microsoft.CodeAnalysis.Text.TextSpan>, IEquatable<Microsoft.CodeAnalysis.Text.TextSpan>
type TextSpan = struct
[<System.Runtime.Serialization.DataContract>]
type TextSpan = struct
Public Structure TextSpan
Implements IComparable(Of TextSpan), IEquatable(Of TextSpan)
Creates a TextSpan instance beginning with the position Start and having the Length specified with length
.
End of the span.
IsEmptyDetermines whether or not the span is empty.
LengthLength of the span.
StartStart point of the span.
Methods CompareTo(TextSpan)Compares current instance of TextSpan with another.
Contains(Int32)Determines whether the position lies within the span.
Contains(TextSpan)Determines whether span
falls completely within this span.
Determines if current instance of TextSpan is equal to another.
Equals(TextSpan)Determines if current instance of TextSpan is equal to another.
FromBounds(Int32, Int32)Creates a new TextSpan from start
and end
positions as opposed to a position and length.
The returned TextSpan contains the range with start
inclusive, and end
exclusive.
Produces a hash code for TextSpan.
Intersection(TextSpan)Returns the intersection with the given span, or null if there is no intersection.
IntersectsWith(Int32)Determines whether position
intersects this span. A position is considered to intersect if it is between the start and end positions (inclusive) of this span.
Determines whether span
intersects this span. Two spans are considered to intersect if they have positions in common or the end of one span coincides with the start of the other span.
Returns the overlap with the given span, or null if there is no overlap.
OverlapsWith(TextSpan)Determines whether span
overlaps this span. Two spans are considered to overlap if they have positions in common and neither is empty. Empty spans do not overlap with any other span.
Provides a string representation for TextSpan. This representation uses "half-open interval" notation, indicating the endpoint character is not included. Example: [10..20)
, indicating the text starts at position 10 and ends at position 20 not included.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide. In this articleWas this page helpful?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4