Info

format will also contain uppercase characters.

These format characters are suffixed to a given placeholder value using the colon token (e.g., {0:C}, {1:d}, {2:X}, and so on). Now, update the Main() method with the following logic:

' Now make use of some format tags.

Sub Main()

Console.WriteLine("C format: {0:C}", 99989.987) Console.WriteLine("D9 format: {0:D9}", 99999) Console.WriteLine("E format: {0:E}", 99999.76543) Console.WriteLine("F3 format: {0:F3}", 99999.9999) Console.WriteLine("N format: {0:N}", 99999) Console.WriteLine("X format: {0:x}", 99999) Console.WriteLine("x format: {0:x}", 99999) End Sub

Here we are defining numerous string literals, each of which has a segment not known until runtime. At runtime, the format character will be used internally by the Console type to print out the entire string in the desired format.

Was this article helpful?

0 0

Post a comment