System.Convert.ToString Method

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

Syntax

public static string ToString (object value, IFormatProvider provider)

Parameters

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

Returns

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

Remarks

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.

Requirements

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