Frequently Asked Interview Questions

What is the Difference Between Convert.ToString() and .ToString() ?

Convert.ToString Vs .ToString()

1. .ToString() can not handle NULL values, Convert.ToString() can handle NULL values.

For Example:
string str2, str = null;
str2 = str.ToString();       // generates a Null reference Exception
str2 = Convert.ToString(str);      // It converts null string to null and assign it to Str2

2.We can not format the string using .ToString(), We can format the string output using Convert.ToString()

Ex:  Convert.ToString(str,IFormatProvider)

Most Visited Pages

Home | Site Index | Contact Us