Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
C# Programming

Formatting Floating Point Values

 

Input and Output

Formatting Floating Point Values

1. [ C# ] Printing a decimal values


Big

The Write method takes a format string as the first parameter. This string is printed but following parameters replace the {} placeholders.

In the phrase {0:8:f3} 0 indicates the first parameter 8 is the number of spaces to use (right justified), f3 means three decimal places.

Format Code Meaning
Simple {0} Simple conversion to string
Three dp {0:f3} Three decimal places.
Right aligned {0,8:f3} Print right aligned in 8 characters. Use three decimal places.