So, to answer your question directly: there is no difference between any of the approaches. There would be a difference in case of an IFormatProvider
overload.
Now to dwelve into details:
Convert.ToString
will try to call IConvertible
and IFormattable
interfaces (in that order) before falling back to base object.ToString
. So if you pass something that does not implement any of these interfaces (or null
on which you can't call any member methods), there will be no difference betweent this and a simple object.ToString
.
Now string interpolation is a case of composite formatting (string interpolation is actually equivalent to calling string.Format
). This one will call only the IFormattable
interface implementation before falling back to object.ToString
. Again, in case of something not implementing the interface (or a null
), no difference.
To make things more complicated, both of these methods contain an overload that takes an IFormatProvider
argument. In case of Convert.ToString
the method will try to call IConvertible.ToString(IFormatProvider)
, if the object implements the IConvertible
interface. Then it tries the IFormattable.ToString(String, IFormatProvider)
and if that fails it falls back to object.ToString()
.
In case of composite formatting, it will try to call the IFormatProvider.GetFormat
method and then use the returned ICustomFormatter
. If that fails it continues to IFormattable
and ultimately falls back to object.ToString
.
When it comes to null
values, there can be a difference when using the IFormatProvider
. Since Convert.ToString
tries to call the IConvertible
implementation, and you can't really call anything on a null
, it treats null
as a special case and returns string.Empty
. However, composite formatting calls the ICustomFormatter.Format
with the object as an argument, so if you use an ICustomFormatter
that handles null
differently, you can get a different result! You can verify it with this code snippet (disclaimer: not the smartest way to implement an IFormatProvider
, but it works as an example).
Here's the MSDN doc for Convert.ToString
.
Here's the MSDN doc for composite formatting (see the Processing Order section).