• Home
  • API documentation
Show / Hide Table of Contents
  • ChessSharp
    • ChessUtilities
    • GameBoard
    • GameState
    • Move
    • Piece
    • Player
  • ChessSharp.Pieces
    • Bishop
    • King
    • Knight
    • Pawn
    • PawnPromotion
    • Queen
    • Rook
  • ChessSharp.SquareData
    • File
    • Rank
    • Square

Class Square

Represents a chess square.

Inheritance
System.Object
Square
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: ChessSharp.SquareData
Assembly: ChessSharp.dll
Syntax
public class Square

Constructors

| Improve this Doc View Source

Square(File, Rank)

Initializes a new instance of the Squareclass.

Declaration
public Square(File file, Rank rank)
Parameters
Type Name Description
File file

A File enum representing the file of the square.

Rank rank

A Rank enum representing the rank of the square.

| Improve this Doc View Source

Square(Char, Int32)

Initializes a new instance of the Square class.

Declaration
public Square(char file, int rank)
Parameters
Type Name Description
System.Char file

A char representing the file of the square.

System.Int32 rank

A char representing the rank of the square.

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Either file or rank is out of range. file should be a char between 'A' and 'H' (case insensitive). rank should be a char between '1' and '8'.

Properties

| Improve this Doc View Source

File

Gets the File of the square.

Declaration
public File File { get; }
Property Value
Type Description
File
| Improve this Doc View Source

Rank

Gets the Rank of the square.

Declaration
public Rank Rank { get; }
Property Value
Type Description
Rank

Methods

| Improve this Doc View Source

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
Overrides
System.Object.Equals(System.Object)
| Improve this Doc View Source

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.Object.GetHashCode()
| Improve this Doc View Source

Parse(String)

Parses a string representation of the square.

Declaration
public static Square Parse(string square)
Parameters
Type Name Description
System.String square

The string representation of the square.

Returns
Type Description
Square

Returns a Square object.

Exceptions
Type Condition
System.ArgumentNullException

The given square string is null.

System.ArgumentException

The given square string has length less or greater than two. The square string should have length of two (For example, "G2").

System.ArgumentOutOfRangeException

Either the file or the rank char of the square string is out of range. The file should be between 'A' and 'H' (case insensitive). The rank should be between '1' and '8'.

| Improve this Doc View Source

ToString()

Converts the given square to a string.

Declaration
public override string ToString()
Returns
Type Description
System.String

Returns string representation of the square. For example, it returns "G2" for a square with G file and second rank.

Overrides
System.Object.ToString()

Operators

| Improve this Doc View Source

Implicit(String to Square)

Declaration
public static implicit operator Square(string s)
Parameters
Type Name Description
System.String s
Returns
Type Description
Square
  • Improve this Doc
  • View Source
Back to top Generated by DocFX