Search code examples
c#.netstringglobalization

Difference between Convert.ToString Method and Object.ToString() with regard to Globalization


Is there any difference between Convert.ToString Method and Object.ToString() in C#.net other than how these handle null value. There could be some difference between the two in Globalization Perspective.


Solution

  • Yes and no.

    For example, the Convert.ToString(int) method, is identical to the Int32.ToString() method, as MSDN states in the 'Remarks' section: "This implementation is identical to Int32.ToString()." However, the Convert class also offers overrides which take an IFormatProvider as a second parameter (e.g. Convert.ToString(int, IFormatProvider)), and this can be used to adjust the output format, e.g. by passing a CultureInfo instance.