TextPosition Struct

A position within a text (offset, line column)

public struct TextPosition : IEquatable<TextPosition>
Implements

Constructors

NameDescription
TextPosition(int, int, int)Creates a new instance of a TextPosition

TextPosition(int, int, int)

TextPosition.cs

Creates a new instance of a TextPosition

public TextPosition(int offset, int line, int column)

Parameters

offset int
Offset in the source text
line int
Line number - zero based
column int
Column number - zero based

Properties

NameDescription
ColumnGets or sets the column number (zero based)
LineGets or sets the line number (zero based)
OffsetGets or sets the offset.

Gets or sets the column number (zero based)

public int Column { readonly get; set; }

Property value

int

Gets or sets the line number (zero based)

public int Line { readonly get; set; }

Property value

int

Gets or sets the offset.

public int Offset { readonly get; set; }

Property value

int

Methods

NameDescription
Equals(TextPosition)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Indicates whether this instance and a specified object are equal.
GetHashCode()Returns the hash code for this instance.
ToString()Returns the fully qualified type name of this instance.

Equals overloads

Equals(TextPosition)

TextPosition.cs

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

public bool Equals(TextPosition other)
Parameters
other TextPosition
An object to compare with this object.
Returns

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

Equals(object?)

TextPosition.cs

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)
Parameters
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()

TextPosition.cs

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()

TextPosition.cs

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string The fully qualified type name.

Operators

NameDescription
operator ==(TextPosition, TextPosition)Compares two TextPosition values for equality.
operator !=(TextPosition, TextPosition)Compares two TextPosition values for inequality.

operator ==(TextPosition, TextPosition)

TextPosition.cs

Compares two TextPosition values for equality.

public static bool operator ==(TextPosition left, TextPosition right)

Parameters

left TextPosition
The left value.
right TextPosition
The right value.

Returns

bool true if the values are equal; otherwise false.

operator !=(TextPosition, TextPosition)

TextPosition.cs

Compares two TextPosition values for inequality.

public static bool operator !=(TextPosition left, TextPosition right)

Parameters

left TextPosition
The left value.
right TextPosition
The right value.

Returns

bool true if the values are not equal; otherwise false.

Fields

NameDescription
EofGets a sentinel position representing end-of-file.

Eof

Gets a sentinel position representing end-of-file.

public static readonly TextPosition Eof