complete-reference-vb_net_21
complete-reference-vb_net_21
To use these functions, you need to reference the Visual Basic Run−Time Library.
String Formatting
As mentioned earlier, the .NET Framework provides three types of format providers. These provide
formatting of numeric Strings, data and time Strings, and Enumeration Strings. These "formatters" are
wired into the ToString methods of the fundamental data types that implement the IFormattable interface,
such as Int32 (Integer), Int64 (Long), Singles, Doubles, DateTime, Enumerator, and the like.
As demonstrated earlier in this chapter and in various places in this book, these formatters are also present in
the workings of the Console and String classes and other classes, such as those in the System.IO namespace,
that process text. See the "Format" section earlier in this chapter.
Classes that provide the formatter "masks" or "patterns, such as {00:00} and separator tokens and decimal
point tokens, are known as format providers. These classes implement the IFormatProvider interface.
The format provider is typically passed to an overloaded ToString method as defined by the IFormattable
interface. If no provider is passed, then the method can be coded to use a default format provider against the
arguments processed to it. In such situations where no providers are passed, the formatting is implicit to the
method, which obtains the mask and its tokens from one of the standard framework format providers.
However, ToString methods typically implement IFormattable to provide the support in one of their
overloaded variations (such as Console.WriteLine).
505