System.Convert.ToString Method

Converts the value of the specified object to its equivalent string representation using the specified culture-specific formatting information.


public static string ToString (object value, IFormatProvider provider)


An object that supplies the value to convert, or null.
An object that supplies culture-specific formatting information.


The string representation of value, or string.Empty if value is null.


If the value parameter implements the IConvertible interface, the method calls the IConvertible.ToString(IFormatProvider) implementation of value. Otherwise, if the value parameter implements the IFormattable interface, the method calls its IFormattable.ToString(string, IFormatProvider) implementation. If value implements neither interface, the method calls the value parameter's ToString() method, and the provider parameter is ignored.

The provider parameter is used if the value parameter implements the IConvertible or IFormattable interface. The most common use of the provider parameter is to specify culture-specific information used in the conversion of value. For example, if the value parameter is a negative decimal number, the provider parameter can supply culture-specific information about the notation used for the negative sign and decimal separator. The second example in the next section illustrates a format provider that does not supply culture-sensitive formatting information.


Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,