IFormatProvider Interface

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Provides a mechanism for retrieving an object to control formatting.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public interface IFormatProvider

The IFormatProvider type exposes the following members.

  NameDescription
Public methodGetFormatReturns an object that provides formatting services for the specified type.
Top

The IFormatProvider interface supplies an object that provides formatting information for formatting and parsing operations. Formatting operations convert the value of a type to the string representation of that value. Typical formatting methods are the ToString methods of a type, as well as Format. Parsing operations convert the string representation of a value to a type with that value. Typical parsing methods are Parse and TryParse.

The IFormatProvider interface consists of a single method, IFormatProvider..::..GetFormat. GetFormat is a callback method: The parsing or formatting method calls it and passes it a Type object that represents the type of object that the formatting or parsing method expects will provide formatting information. The GetFormat method is responsible for returning an object of that type.

Show: