complete-reference-vb_net_22
complete-reference-vb_net_22
The key format providers that implement the IFormatProvider interface are listed as follows:
In cases where formatting information is needed but no IFormatProvider is supplied, the CultureInfo object
associated with the current thread is usually used.
NumberFormatInfo
The standard NumberFormatInfo String comprises a character that represents the format, such as currency
or decimal, followed by digits that represent the precision. Table 15−4 lists the standard formats supported by
the Format method.
Currency
The Currency formatter is used to convert the given numerical value to a currency value. The currency value
can contain a locale−specific currency amount. The format information is determined by the current locale,
but you can override this by passing in the NumberFormatInfo object as an argument. The default in the
United States is, of course, USD. For example:
Console.WriteLine("{0:c}", 1250.99)
Console.WriteLine("{0:c}", −1250.99)
Tip The Console.WriteLine method automatically calls String.Format as demonstrated in the preceding and
following examples (as does ToString if the argument can be formatted as defined by the IFormattable
interface).
Table 15−4: The Built−in Formatters, or Format Providers, that Implement IFormatProvider
$1,250.99
($1,250.99)
506