C# UInt32 ToString(String, IFormatProvider)
Description
UInt32 ToString(String, IFormatProvider)
converts
the numeric value of this instance to its equivalent string representation
using the specified format and culture-specific format information.
Syntax
UInt32.ToString(String, IFormatProvider)
has the following syntax.
public string ToString(
string format,
IFormatProvider provider
)
Parameters
UInt32.ToString(String, IFormatProvider)
has the following parameters.
format
- A numeric format string.provider
- An object that supplies culture-specific formatting information about this instance.
Returns
UInt32.ToString(String, IFormatProvider)
method returns The string representation of the value of this instance as specified by format
and provider.
Example
The following example displays a 32-bit unsigned integer value by using the standard numeric format specifiers and a number of specific CultureInfo objects.
//from w ww.j av a 2 s .c o m
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
CultureInfo[] cultures = { CultureInfo.CreateSpecificCulture("en-US"),
CultureInfo.CreateSpecificCulture("fr-FR"),
CultureInfo.CreateSpecificCulture("es-ES") };
string[] specifiers = {"G", "C", "D4", "E2", "F", "N", "P", "X2"};
uint value = 1234567;
foreach (string specifier in specifiers)
{
foreach (CultureInfo culture in cultures)
Console.WriteLine("{0,2} format using {1} culture: {2, 18}",
specifier, culture.Name,
value.ToString(specifier, culture));
Console.WriteLine();
}
}
}
The code above generates the following result.