Table of Contents

Struct TextPosition

Namespace
Farkle
Assembly
Farkle.dll

Represents the position of a character in text.

public readonly struct TextPosition : IEquatable<TextPosition>, ISpanFormattable, IFormattable
Implements

Properties

Column

The column number of the TextPosition, starting from 1.

public int Column { get; }

Property Value

int

Initial

A TextPosition that points to the start of text.

public static TextPosition Initial { get; }

Property Value

TextPosition

Line

The line number of the TextPosition, starting from 1.

public int Line { get; }

Property Value

int

Methods

Create0(int, int)

Creates a TextPosition from zero-based coordinates.

public static TextPosition Create0(int line, int column)

Parameters

line int

The line coordinate, starting from zero.

column int

The column coordinate, starting from zero.

Returns

TextPosition

Exceptions

ArgumentOutOfRangeException

line or column are smaller than zero.

Create1(int, int)

Creates a TextPosition from one-based coordinates.

public static TextPosition Create1(int line, int column)

Parameters

line int

The line coordinate, starting from one.

column int

The column coordinate, starting from one.

Returns

TextPosition

Exceptions

ArgumentOutOfRangeException

line or column are smaller than one.

Equals(TextPosition)

Checks two TextPositions for equality.

public bool Equals(TextPosition other)

Parameters

other TextPosition

The other position.

Returns

bool

Whether this and other have the same Line and Column values.

Equals(object?)

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

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

Formats the TextPosition to a string.

public override string ToString()

Returns

string

The string (Line, Column)

Operators

operator ==(TextPosition, TextPosition)

Implements the equality operator for TextPosition.

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

Parameters

left TextPosition

The first position.

right TextPosition

The second position.

Returns

bool

Whether the two positions are equal.

operator !=(TextPosition, TextPosition)

Implements the inequality operator for TextPosition.

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

Parameters

left TextPosition

The first position.

right TextPosition

The second position.

Returns

bool

Whether the two positions are not equal.