There is no difference between i.ToString() and Convert.ToString(i).
This is the body of the Convert method:
public static string ToString(int value)
{
return value.ToString();
}
Furthermore, the integer variable cannot be null since its a value type.
Kuju wrote:
Hi
There is no difference between i.ToString() and Convert.ToString(i).
This is the body of the Convert method:
public static string ToString(int value)
{
return value.ToString();
}
Furthermore, the integer variable cannot be null since its a value type.
Kuju is absolutely correct.But what will happen if tostring is to be used with an custom object
public static string ToString(object value, IFormatProvider provider)
{
IConvertible convertible = value as IConvertible
if(convertible != null)
{
return convertible.ToString(provider)
}
if(value != null)
{
return value.ToString();
}
return string.Empty
}