This documentation is archived and is not being maintained.

IFormattable Interface

Provides functionality to format the value of an object into a string representation.

For a list of all members of this type, see IFormattable Members.

[Visual Basic]
Public Interface IFormattable
public interface IFormattable
public __gc __interface IFormattable
public interface IFormattable

Classes that Implement IFormattable

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 nonnegative 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 Overview.


Namespace: System

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: Mscorlib (in Mscorlib.dll)

See Also

IFormattable Members | System Namespace | Formatting Overview | IFormatProvider | Object.ToString | CurrentCulture