In This Article

TextSnapshotOffset Struct

Represents a zero-based offset value within a certain ITextSnapshot.

public readonly struct TextSnapshotOffset : IComparable<TextSnapshotOffset>, IComparable<int>, IEquatable<TextSnapshotOffset>, ITextRangeProvider
Implements:
IComparable<TextSnapshotOffset> IComparable<int> IEquatable<TextSnapshotOffset> ITextRangeProvider

Constructors

TextSnapshotOffset(ITextSnapshot, int)

Represents a zero-based offset value within a certain ITextSnapshot.

public TextSnapshotOffset(ITextSnapshot snapshot, int offset)
Parameter Type Description
snapshot ITextSnapshot

The ITextSnapshot that contains the offset.

offset int

The zero-based offset.

Properties

Column

The zero-based column value, which accounts for the document's tab size.

public int Column { get; }

Property Value

int

Line

The ITextSnapshotLine that contains the offset.

public ITextSnapshotLine Line { get; }

Property Value

ITextSnapshotLine

Offset

The zero-based offset value.

public int Offset { get; }

Property Value

int

Position

The TextPosition for the offset.

public TextPosition Position { get; }

Property Value

TextPosition

Snapshot

The ITextSnapshot that contains the offset.

public ITextSnapshot Snapshot { get; }

Property Value

ITextSnapshot

Methods

CompareTo(TextSnapshotOffset)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(TextSnapshotOffset snapshotOffset)
Parameter Type Description
snapshotOffset TextSnapshotOffset

Returns

int:

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

CompareTo(int)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(int value)
Parameter Type Description
value int

Returns

int:

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

Equals(TextSnapshotOffset)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(TextSnapshotOffset other)
Parameter Type Description
other TextSnapshotOffset

An object to compare with this object.

Returns

bool:

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)
Parameter Type Description
obj object

The object to compare with the current instance.

Returns

bool:

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int:

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

TranslateTo(ITextSnapshot, TextOffsetTrackingMode)

Translates this offset from one ITextSnapshot to another in the same ITextDocument.

public TextSnapshotOffset TranslateTo(ITextSnapshot toSnapshot, TextOffsetTrackingMode trackingMode)
Parameter Type Description
toSnapshot ITextSnapshot

The ITextSnapshot that is the target of the translation.

trackingMode TextOffsetTrackingMode

A TextOffsetTrackingMode indicating the tracking mode to use.

Returns

TextSnapshotOffset:

The translated TextSnapshotOffset.

Operators

operator ==(TextSnapshotOffset, TextSnapshotOffset)

Compares two TextSnapshotOffset objects. The result specifies whether the values of the Offset properties of the two TextSnapshotOffset objects are equal.

public static bool operator ==(TextSnapshotOffset left, TextSnapshotOffset right)
Parameter Type Description
left TextSnapshotOffset

A TextSnapshotOffset to compare.

right TextSnapshotOffset

A TextSnapshotOffset to compare.

Returns

bool:

true if the Offset values of left and right are equal; otherwise, false.

operator >(TextSnapshotOffset, TextSnapshotOffset)

Compares whether one TextSnapshotOffset is greater than the other.

public static bool operator >(TextSnapshotOffset left, TextSnapshotOffset right)
Parameter Type Description
left TextSnapshotOffset

A TextSnapshotOffset to compare.

right TextSnapshotOffset

A TextSnapshotOffset to compare.

Returns

bool:

true if the TextSnapshotOffset in left is greater than the TextSnapshotOffset in right; otherwise, false.

operator >=(TextSnapshotOffset, TextSnapshotOffset)

Compares whether one TextSnapshotOffset is greater than or equal to the other.

public static bool operator >=(TextSnapshotOffset left, TextSnapshotOffset right)
Parameter Type Description
left TextSnapshotOffset

A TextSnapshotOffset to compare.

right TextSnapshotOffset

A TextSnapshotOffset to compare.

Returns

bool:

true if the TextSnapshotOffset in left is greater than or equal to the TextSnapshotOffset in right; otherwise, false.

implicit operator int(TextSnapshotOffset)

Implicitly converts a TextSnapshotOffset instance to an integer offset.

public static implicit operator int(TextSnapshotOffset snapshotOffset)
Parameter Type Description
snapshotOffset TextSnapshotOffset

The TextSnapshotOffset to convert.

Returns

int:

The integer offset result.

operator !=(TextSnapshotOffset, TextSnapshotOffset)

Compares two TextSnapshotOffset objects. The result specifies whether the values of the Offset properties of the two TextSnapshotOffset objects are unequal.

public static bool operator !=(TextSnapshotOffset left, TextSnapshotOffset right)
Parameter Type Description
left TextSnapshotOffset

A TextSnapshotOffset to compare.

right TextSnapshotOffset

A TextSnapshotOffset to compare.

Returns

bool:

true if the Offset values of left and right are unequal; otherwise, false.

operator <(TextSnapshotOffset, TextSnapshotOffset)

Compares whether one TextSnapshotOffset is less than the other.

public static bool operator <(TextSnapshotOffset left, TextSnapshotOffset right)
Parameter Type Description
left TextSnapshotOffset

A TextSnapshotOffset to compare.

right TextSnapshotOffset

A TextSnapshotOffset to compare.

Returns

bool:

true if the TextSnapshotOffset in left is less than the TextSnapshotOffset in right; otherwise, false.

operator <=(TextSnapshotOffset, TextSnapshotOffset)

Compares whether one TextSnapshotOffset is less than or equal to the other.

public static bool operator <=(TextSnapshotOffset left, TextSnapshotOffset right)
Parameter Type Description
left TextSnapshotOffset

A TextSnapshotOffset to compare.

right TextSnapshotOffset

A TextSnapshotOffset to compare.

Returns

bool:

true if the TextSnapshotOffset in left is less than or equal to the TextSnapshotOffset in right; otherwise, false.

Inherited Members