System Namespace
Provides functionality to format the value of an object into a string representation.
Class |
Description |
Enum |
Provides the base class for enumerations. |
IFormattable is implemented by the base data types.
A format describes the appearance of an object when it is converted to a string. A format can be either standard or custom. A standard format takes the form Axx, where A is an alphabetic character called the format specifier, and xx is a non-negative integer called the precision specifier. The format specifier controls the type of formatting applied to the value being represented as a string. The precision specifier controls the number of significant digits or decimal places in the string, if applicable.
When a format includes symbols that vary by culture, such as the currency symbol represented by the "C" and "c" formats, a formatting object supplies the actual characters used in the string representation. A method might include a parameter to pass an IFormatProvider object that supplies a formatting object, or the method might use the default formatting object, which contains the symbol definitions for the current thread. The current thread typically uses the same set of symbols used system-wide by default.
Notes to Implementers:
Classes that require more control over the formatting of strings than Object.ToString provides should implement IFormattable, whose ToString method uses the current thread's CurrentCulture property.
A class that implements IFormattable must support the "G" ( general ) formatting code. Besides the "G" code, the class can define the list of formatting codes that it supports.
For more information on formatting and formatting codes, see Formatting Base Types.
Formatting Base Types IFormatProvider Object.ToString CurrentCulture