ToString Method (IFormatProvider)
Collapse the table of content
Expand the table of content

UInt32.ToString Method (IFormatProvider)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

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

'Declaration
Public Function ToString ( _
	provider As IFormatProvider _
) As String

Parameters

provider
Type: System.IFormatProvider
An object that supplies culture-specific formatting information.

Return Value

Type: System.String
The string representation of the value of this instance, which consists of a sequence of digits ranging from 0 to 9, without a sign or leading zeros.

Implements

IConvertible.ToString(IFormatProvider)

This instance is formatted with the general numeric format specifier ("G"). The string representation of the UInt32 value consists of a sequence of digits ranging from 0 to 9 without leading zeros.

The provider parameter is an IFormatProvider implementation. Its GetFormat method returns a NumberFormatInfo object that provides culture-specific formatting information. However, none of the properties of the NumberFormatInfo are used when formatting with the general numeric format specifier ("G").

The following example formats a 16-bit signed integer value by using several format providers, including one for the invariant culture. The output from the example illustrates that the formatted string returned by the ToString(IFormatProvider) method is the same regardless of the format provider.


Imports System.Globalization

Module Example
   Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      ' Define an array of CultureInfo objects.
      Dim ci() As CultureInfo = {New CultureInfo("en-US"), _
                                  New CultureInfo("fr-FR"), _
                                  CultureInfo.InvariantCulture}
      Dim value As UInteger = 1870924
      outputBlock.Text += String.Format("  {0,12}   {1,12}   {2,12}", _
                        GetName(ci(0)), GetName(ci(1)), GetName(ci(2))) & vbCrLf
      outputBlock.Text += String.Format("  {0,12}   {1,12}   {2,12}", _
                        value.ToString(ci(0)), value.ToString(ci(1)), value.ToString(ci(2))) & vbCrLf

   End Sub

   Private Function GetName(ByVal ci As CultureInfo) As String
      If ci.Equals(CultureInfo.InvariantCulture) Then
         Return "Invariant"
      Else
         Return ci.Name
      End If
   End Function
End Module
' The example displays the following output:
'        en-US          fr-FR      Invariant
'      1870924        1870924        1870924


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft