0

I am trying to print a jagged array with a some kind of 'constant row spacing' to make it more clear to read. Here's default output which I receive :

enter image description here

And I wish to receive something similar to this :

enter image description here

Here is my array printing code :

 for (int i = 0; i < level; i++)
            {
                for (int j = 0; j < level; j++)
                    Console.Write(string.Format("{0}   ", matrix[i][j].ToString("0.00")));
                Console.Write(Environment.NewLine + Environment.NewLine);
            }

Any quick and simple way to reach this?

2
  • 1
    use \t instead of spaces. if its still not good for large numbers use \t\t. Commented Dec 6, 2015 at 16:16
  • 3
    Check this answer, it can be helfpul Commented Dec 6, 2015 at 16:17

1 Answer 1

3

Here's an example for padding with width of 5 to the left

string.Format("{0:-5}", matrix[i][j].ToString("0.00"))

You can see here more options how you can pad with spaces

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.