MatrixWalk.MatrixRotatingWalk.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : string
return string
        public override string ToString()
        {
            StringBuilder matrixAsStirng = new StringBuilder();

            for (int row = 0; row < this.dimentions; row++)
            {
                for (int col = 0; col < this.dimentions; col++)
                {
                    matrixAsStirng.AppendFormat("{0,3}", this.matrix[row, col]);
                }

                matrixAsStirng.Append(Environment.NewLine);
            }

            return matrixAsStirng.ToString();
        }

Usage Example

Example #1
0
        public void SixDimentionTest()
        {
            MatrixRotatingWalk matrix = new MatrixRotatingWalk(6);

            Assert.AreEqual(matrix.ToString(), string.Format("{0}{6}{1}{6}{2}{6}{3}{6}{4}{6}{5}{6}",
                                                            "  1 16 17 18 19 20",
                                                            " 15  2 27 28 29 21",
                                                            " 14 31  3 26 30 22",
                                                            " 13 36 32  4 25 23",
                                                            " 12 35 34 33  5 24",
                                                            " 11 10  9  8  7  6",
                                                            Environment.NewLine));
        }
All Usage Examples Of MatrixWalk.MatrixRotatingWalk::ToString