Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

IFormattable.ToString Method

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

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

'Declaration
Function ToString ( _
	format As String, _
	formatProvider As IFormatProvider _
) As String
'Usage
Dim instance As IFormattable
Dim format As String
Dim formatProvider As IFormatProvider
Dim returnValue As String

returnValue = instance.ToString(format, formatProvider)
String ToString (
	String format, 
	IFormatProvider formatProvider
)
function ToString (
	format : String, 
	formatProvider : IFormatProvider
) : String
Not applicable.

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.

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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.