This documentation is archived and is not being maintained.

IFormattable.ToString Method

Formats the value of the current instance using the specified format.

[Visual Basic]
Function ToString( _
   ByVal format As String, _
   ByVal formatProvider As IFormatProvider _
) As String
string ToString(
   string format,
 IFormatProvider formatProvider
String* ToString(
   String* format,
 IFormatProvider* formatProvider
function ToString(
   format : String,
 formatProvider : IFormatProvider
) : String;


The String specifying the format to use.


A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

The IFormatProvider to use to format the value.


A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Return Value

A String containing the value of the current instance in the specified format.


NumberFormatInfo, DateTimeFormatInfo and CultureInfo implement the IFormatProvider interface.

NumberFormatInfo supplies numeric formatting information, such as the characters to use for decimal and thousand separators and the spelling and placement of currency symbols in monetary values.

DateTimeFormatInfo supplies date- and time-related formatting information, such as the position of the month, the day and the year in a date pattern.

CultureInfo contains the default formatting information in a specific culture, including the numeric format information and date- and time-related formatting information.


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, Common Language Infrastructure (CLI) Standard

See Also

IFormattable Interface | IFormattable Members | System Namespace | String | IFormatProvider | System.Globalization.NumberFormatInfo | System.Globalization.DateTimeFormatInfo | System.Globalization.CultureInfo