Sudoku.Board.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : string
return string
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 8; i >= 0; i--)
            {
                sb.Append("+-+-+-+-+-+-+-+-+-+");
                sb.Append("\n");
                sb.Append("|");
                for (int j = 0; j < 9; j++)
                {
                    var v = GetCellValue((Columns)j, (Rows)i);
                    string s = " ";
                    if (v == Values.One) s = "1";
                    if (v == Values.Two) s = "2";
                    if (v == Values.Three) s = "3";
                    if (v == Values.Four) s = "4";
                    if (v == Values.Five) s = "5";
                    if (v == Values.Six) s = "6";
                    if (v == Values.Seven) s = "7";
                    if (v == Values.Eight) s = "8";
                    if (v == Values.Nine) s = "9";
                    if (v == Values.None) s = "0";

                    sb.Append(s);
                    sb.Append("|");

                }
                sb.Append("\n");
            }
            sb.Append("+-+-+-+-+-+-+-+-+-+");
            return sb.ToString();
        }

Usage Example

Example #1
0
 public void killSolver()
 {
     foreach(Thread thread in threads)
     {
         thread.Abort();
     }
     PresentBoard?.Invoke(this, new PresentBoardArgs(solution.ToString()));
     SolveEnded?.Invoke(this, new SolveEndedArgs(solution.isComplete(), "중단되었습니다."));
 }
All Usage Examples Of Sudoku.Board::ToString