Click here to Skip to main content
16,020,347 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am trying to print my answer in one row below another from the following codes. Like
Output
disk: 1 2 3 4 5
move: 1 2 7 15 31
Can someone help me out?

C#
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 2;

            for (int j = 1; j <= 5; j++)
                Console.WriteLine("disk: {0}", j);

            for (int i = 1; i <= 5; i++)
                    Console.WriteLine("moves: {2:N0}",
                                      n, i,(long)Math.Pow(n, i) - 1);

        }

    }
}
Posted

1 solution

See: http://msdn.microsoft.com/en-us/library/txafckwd.aspx[^]


Format Item Syntax
--------------------------------------------------------------------------------
Each format item takes the following form and consists of the following components:
{ index[,alignment][:formatString]}
The matching braces ("{" and "}") are required.



Alignment Component
--------------------------------------------------------------------------------
The optional alignment component is a signed integer indicating the preferred formatted field width. If the value of alignment is less than the length of the formatted string, alignment is ignored and the length of the formatted string is used as the field width. The formatted data in the field is right-aligned if alignment is positive and left-aligned if alignment is negative. If padding is necessary, white space is used. The comma is required if alignment is specified.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900