Use format commands: indicate the parameter sequence : Console Output Format « Development « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Development » Console Output Format 
14.4.9.Use format commands: indicate the parameter sequence
using System; 
 
class Example {    
  public static void Main() {    
    int i; 
 
    Console.WriteLine("Value\tSquared\tCubed")
 
    for(i = 1; i < 10; i++
      Console.WriteLine("{0}\t{1}\t{2}",  
                        i, i*i, i*i*i)
  }    
}
Value   Squared Cubed
1       1       1
2       4       8
3       9       27
4       16      64
5       25      125
6       36      216
7       49      343
8       64      512
9       81      729
14.4.Console Output Format
14.4.1.Format: Allignment
14.4.2.Format: Currency
14.4.3.Format: {0,-10:G}
14.4.4.Format: {0,-10}
14.4.5.Format: {0,-10:F4} -- Fixed Point, 4 decimal places
14.4.6.Format: {0,-10:C} -- Currency
14.4.7.Format: {0,-10:E3} -- Sci. Notation, 3 dec places
14.4.8.Format: {0,-10:x} -- Hexadecimal integer
14.4.9.Use format commands: indicate the parameter sequence
14.4.10.Use the C format specifier to output dollars and cents.
14.4.11.Format double value
14.4.12.Numeric formatting specifiers
14.4.13.Display 4 mandatory and 3 optional arguments using the Console.WriteLine method.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.