This documentation is archived and is not being maintained.

ICustomFormatter Interface

Defines a method that supports custom, user-defined formatting of the value of an object.

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

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


When this interface is implemented by a reference or value type, the Format method returns a custom-formatted string representation of an object's value.

Use this interface, and the IFormatProvider interface, to supersede the support supplied in .NET Framework formatting methods that honor an IFormatProvider parameter. For example, use this interface to provide custom formatting of the value of an object by the String.Format or Int32.ToString methods.

Derive a class that implements the IFormatProvider interface and its GetFormat method. Specify that derived class for the IFormatProvider parameter of the method you want to supersede. Your implementation of the GetFormat method should return a format object that implements the ICustomFormatter interface. The .NET Framework method will then use your custom formatting instead of its own.


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

ICustomFormatter Members | System Namespace | IFormatProvider