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
Initial
A TextPosition that points to the start of text.
public static TextPosition Initial { get; }
Property Value
Line
The line number of the TextPosition, starting from 1.
public int Line { get; }
Property Value
Methods
Create0(int, int)
Creates a TextPosition from zero-based coordinates.
public static TextPosition Create0(int line, int column)
Parameters
line
intThe line coordinate, starting from zero.
column
intThe column coordinate, starting from zero.
Returns
Exceptions
- ArgumentOutOfRangeException
line
orcolumn
are smaller than zero.
Create1(int, int)
Creates a TextPosition from one-based coordinates.
public static TextPosition Create1(int line, int column)
Parameters
line
intThe line coordinate, starting from one.
column
intThe column coordinate, starting from one.
Returns
Exceptions
- ArgumentOutOfRangeException
line
orcolumn
are smaller than one.
Equals(TextPosition)
Checks two TextPositions for equality.
public bool Equals(TextPosition other)
Parameters
other
TextPositionThe other position.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe 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
Operators
operator ==(TextPosition, TextPosition)
Implements the equality operator for TextPosition.
public static bool operator ==(TextPosition left, TextPosition right)
Parameters
left
TextPositionThe first position.
right
TextPositionThe 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
TextPositionThe first position.
right
TextPositionThe second position.
Returns
- bool
Whether the two positions are not equal.