Complete-Reference-Vb Net 28
Complete-Reference-Vb Net 28
123456.700
12345.670
1.235
The group separator is a comma (,) and can be used to format large numbers to make them easier to read. You
typically add the comma three places after the decimal point to specify a number such as 1,000.00 or higher.
The character used as the specifier can also be customized in the NumberFormatInfo class. The following
example illustrates placement of the group separator:
Console.WriteLine("{0:##,###}", 123456.7)
Console.WriteLine("{0:##,###,000.000}", 1234567.1234567)
Console.WriteLine("{0:#,#.000}", 1234567.1234567)
123,457
1,234,567.123
1,234,567.123
You can use the percent (%) specifier to denote that a number be displayed as a percentage. The number will
be multiplied by 100 before formatting. In the following example:
Console.WriteLine("{0:##,000%}", 123.45)
Console.WriteLine("{0:00%}", 0.123)
12,345%
12%
When you need to constantly work with a String, such as an algorithm that takes UNC paths and converts
them to HTML paths, or when you need a storage location to shove characters into, like a stack, then you need
to turn to the StringBuilder class. This class can be found on the System.Text.StringBuilder namespace and
allows you to keep working with a String of characters represented by the same objects for as long as it is
needed. The great feature of the object is that you get to reference the collection of characters as a single
Stringfar less code than that "soda−fountain" Stack that requires extensive "popping."
Note In the BitShifters code in Chapter 5, we used the StringBuilder object, albeit in C# garb, as a place to
stuff bits.
512