This is used in Console.WriteLine and also string.format hence its inclusion here.
Layout of the PlaceHolder
The three parts areindex, alignment : formatSo {0:X} (x means Hexadecimal) or {0,10} meaning output in a width of 10. The alignment value specifies teh width and left or right alignment by using - (left aligned) or + (right aligned) numbers. 10 Means right aligned in a width of 10, -6 means left aligned in a width of 6. Alignment is ignored if the output exceeds the width.
This provides a large number of formatting examples.
List of Numeric Formats
- C or C - For Currency. Uses the cultures currency symbol.
- D or D - Integer types. Add a number for 0 padding eg D5.
- E or e - Scientific notation.
- F or f - Fixed Point.
- G or g - Compact fixed-point/scientific notation.
- N or n - Number. This can be enhanced by a NumberFormatInfo object.
- P or p - Percentage.
- R or r - Round-trip. Keeps exact digits when converted to string and back.
- X or x - Hexadecimal. x - uses abcdef, X use ABCDEF.
- O or o - YYYY-MM-dd:mm:ss:ffffffffzz
- R or r - RFC1123 eg ddd, dd MMM yyyy HH:ss GMT
- s - sortable . yyyy-MM-ddTHH:mm:ss
- u - Universal Sort Date - yyyy-MM-dd HH:mm:ssZ
This concludes this tutorial. The next C# programming tutorial will be on Windows forms.

