Basic Output

Output Options

Console.WriteLine (“format string”, arg0, arg1, arg2, ………, argN);

Type 1.1:

Code:
Console.WriteLine(“February has {0,15} or {1,32} days.” , 28, 29);

Output:
February has 28 or 29 days.

Type 1.2:

Code:
Console.WriteLine (“February has {0,15} or {1,32} days.” , 28, 29);

Output:
February has [this gap is made for 15] 28 or [this gap is made for 32] 29 days.

Type 2:

Code:

int i;
Console.WriteLine (“Value\tSquared\tCubed”);

for ( i =1; i <6; i++) Console.WriteLine(“(0)\t(1)\t(2)” , i, i*i, i*i*i );

Output:

Value             Squared               Cubed

1                          1                          1

2                          4                          8

3                          9                          27

4                         16                         64

5                         25                        125

Type 3.1:

sign: { #.##}

Code:
Console.WriteLine (“The result is: {0:#.##}”, 10.0/3.0);

Output:

The result is 3.33 (numbers after the decimals are depened on the number of “#” sign put after “.” in the code)

Type 3.2:

Code:

Console.WriteLine (“The result is: {0:###,####.##}”, 123456.56);

Output:

The result is 123,456.56

Type 4.1:

Code:
Console.WriteLine ( @ “Here is some tabbed output:
1        2        3       4
5        6        7      8” );

Output:

Here is some tabbed output:
1        2        3        4
5       6         7        8

Type 4.2:

Code:
Console.WriteLine ( @ “Programmers’ say, “I like C#.” “);

Output:
Programmers’ say, “I like C#.”