다음을 통해 공유


TextSpan Struct

Definition

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)
Inheritance
TextSpan
Attributes
Implements

Constructors

TextSpan(Int32, Int32)

Creates a TextSpan instance beginning with the position Start and having the Length specified with length.

Properties

End

End of the span.

IsEmpty

Determines whether or not the span is empty.

Length

Length of the span.

Start

Start 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.

Equals(Object)

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.

GetHashCode()

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.

IntersectsWith(TextSpan)

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.

Overlap(TextSpan)

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.

ToString()

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.

Operators

Equality(TextSpan, TextSpan)

Determines if two instances of TextSpan are the same.

Inequality(TextSpan, TextSpan)

Determines if two instances of TextSpan are different.

Applies to