IFormattable::ToString Method

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

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

No code example is currently available or this language may not be supported.

Parameters

format
Type: System::String
The String specifying the format to use.
-or-
nullptr to use the default format defined for the type of the IFormattable implementation.
formatProvider
Type: System::IFormatProvider
The IFormatProvider to use to format the value.
-or-
nullptr to obtain the numeric format information from the current locale setting of the operating system.

Return Value

Type: System::String
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.

The following code example demonstrates implementing the ToString method. This code example is part of a larger example provided for the IFormattable class.

No code example is currently available or this language may not be supported.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: