System.IFormatProvider Interface

Assembly: Mscorlib.dll
Namespace: System
Summary
Provides a mechanism for retrieving an object to control formatting.
C# Syntax:
public interface IFormatProvider
Remarks
Some methods in the common language runtime convert a value to or from a string representation and take a string parameter that contains one or more characters, called format specifiers, which indicate how the value is to be converted. If the meaning of the format specifier varies by culture, a formatting object supplies the actual characters used in the string representation.

A class or value type implements the IFormatProvider.GetFormat method of this interface to obtain an object that provides format information or processing for the implementing type.

For example, IFormatProvider is implemented by NumberFormatInfo and DateTimeFormatInfo. NumberFormatInfo provides culture-specific information used to format numbers in the base data types, and DateTimeFormatInfo provides culture-specific information used to format date and time values.

See also:
System Namespace | ICustomFormatter | IFormattable

System.IFormatProvider Member List:

Public Methods
GetFormat Gets an object that provides formatting services for the specified type.

System.IFormatProvider Member Details

Method: GetFormat(
   Type formatType
)
Summary
Gets an object that provides formatting services for the specified type.
C# Syntax:
object GetFormat(
   Type formatType
);
Parameters:

formatType

An object that specifies the type of format object to get.

Return Value:
A format object of type formatType.

-or-

A format object for the current culture if no format object is available or formatType is null.

Remarks
Implement this method in classes that use format objects in methods that either generate or parse string representations of objects. The ToString and Parse methods are examples of these types of methods.

For more information, see the CultureInfo.CurrentCulture topic.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.