Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
The string representation of the value of this instance as specified by format and provider.
Type Reason FormatException format is invalid.
The uint.ToString(string, IFormatProvider) method formats a uint value in a specified format by using the System.Globalization.NumberFormatInfo object of a specified culture. If you want to use default format or culture settings, use the other overloads of the uint.ToString(string) method, as follows:
Default ("G") format |
Default (current) culture | |
Default ("G") format |
A specific culture | |
A specific format |
Default (current) culture |
The format parameter can be any valid standard numeric format specifier, or any combination of custom numeric format specifiers. If format is equal to string.Empty or is null, the return value of the current uint object is formatted with the general format specifier ("G"). If format is any other value, the method throws a FormatException.
The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:
For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.
For more information about formatting, see Formatting Types.
The provider parameter is an IFormatProvider implementation. Its IFormatProvider.GetFormat(Type) method returns a System.Globalization.NumberFormatInfo object that provides culture-specific information about the format of the string returned by this method. When the uint.ToString(string, IFormatProvider) method is invoked, it calls the provider parameter's IFormatProvider.GetFormat(Type) method and passes it a Type object that represents the System.Globalization.NumberFormatInfo type. The IFormatProvider.GetFormat(Type) method then returns the System.Globalization.NumberFormatInfo object that provides information for formatting the current uint value, such as the group separator symbol or the decimal point symbol. There are three ways to use the provider parameter to supply formatting information to the uint.ToString(string, IFormatProvider) method:
You can pass a System.Globalization.CultureInfo object that represents the culture that supplies formatting information. Its System.Globalization.CultureInfo.GetFormat(Type) method returns the System.Globalization.NumberFormatInfo object that provides numeric formatting information for that culture.
You can pass the actual System.Globalization.NumberFormatInfo object that provides numeric formatting information. (Its implementation of System.Globalization.NumberFormatInfo.GetFormat(Type) just returns itself.)
You can pass a custom object that implements IFormatProvider. Its IFormatProvider.GetFormat(Type) method instantiates and returns the System.Globalization.NumberFormatInfo object that provides formatting information.
If provider is null, the formatting of the returned string is based on the System.Globalization.NumberFormatInfo object of the current culture.