Export (0) Print
Expand All

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
[C#]
string ToString(
   string format,
 IFormatProvider formatProvider
);
[C++]
String* ToString(
   String* format,
 IFormatProvider* formatProvider
);
[JScript]
function ToString(
   format : String,
 formatProvider : IFormatProvider
) : String;

Parameters

format
The String specifying the format to use.

-or-

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

formatProvider
The IFormatProvider to use to format the value.

-or-

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.

Remarks

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.

Requirements

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

Show:
© 2014 Microsoft