UInt64.ToString Method (IFormatProvider)
Microsoft Silverlight will reach end of support after October 2021. Learn more.
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)
Syntax
'Declaration
<SecuritySafeCriticalAttribute> _
Public Function ToString ( _
provider As IFormatProvider _
) As String
[SecuritySafeCriticalAttribute]
public string ToString(
IFormatProvider provider
)
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 as specified by provider.
Implements
Remarks
This instance is formatted with the general numeric format specifier ("G"). The string representation of the UInt64 value consists of a sequence of digits ranging from 0 to 9 without leading zeros.
Note: |
---|
Because the UInt64 data type is not supported on the Macintosh OS X operating system, the string representation of a UInt64 value may be different from the string representations of other .NET Framework numeric types that are supported by OS X. |
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").
Examples
The following example formats a 64-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
Imports System.Windows.Media
Module Example
Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
outputBlock.FontFamily = New FontFamily("Courier New")
' Define an array of CultureInfo objects.
Dim ci() As CultureInfo = {New CultureInfo("en-US"), _
New CultureInfo("fr-FR"), _
CultureInfo.InvariantCulture}
Dim value As ULong = 18709243
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
' 18709243 18709243 18709243
using System;
using System.Globalization;
using System.Windows.Media;
public class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
outputBlock.FontFamily = new FontFamily("Courier New");
// Define an array of CultureInfo objects.
CultureInfo[] ci = { new CultureInfo("en-US"),
new CultureInfo("fr-FR"),
CultureInfo.InvariantCulture };
ulong value = 18709243;
outputBlock.Text += String.Format(" {0,12} {1,12} {2,12}",
GetName(ci[0]), GetName(ci[1]), GetName(ci[2])) + "\n";
outputBlock.Text += String.Format(" {0,12} {1,12} {2,12}",
value.ToString(ci[0]), value.ToString(ci[1]), value.ToString(ci[2])) + "\n";
}
private static string GetName(CultureInfo ci)
{
if (ci.Equals(CultureInfo.InvariantCulture))
return "Invariant";
else
return ci.Name;
}
}
// The example displays the following output:
// en-US fr-FR Invariant
// 18709243 18709243 18709243
Version Information
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
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
See Also