Difference between .Tostring() and convert.Tostring()
Difference between .Tostring() and convert.Tostring() explain with example.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
hj jh81 reputationPosted Aug 27, 2012, 3:25 AM EDT
So as a good programming practice , use convert.tostring().
Please accept as answer if your problem resolved!
Girish Barje7 reputationPosted Aug 27, 2012, 3:26 AM EDT
Convert.ToString()handlesnull, whileToString()doesn't.Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 27, 2012, 4:10 AM EDT
ToString() raise exception when the object is null
Convert.ToString() return string.Empty in case of null object
string o = NullObject.ToString(); // Give runtime exception.
string o1 = Convert.ToString(NullObject); // not give any runtime exception.
hope this will help you.
rahul jaiswal166 reputationPosted Aug 27, 2012, 4:11 AM EDT
ToString()on an object presumes that the object is not null (since an object needs to exist to call an instance method on it).Convert.ToString(obj)doesn't need to presume the object is not null (as it is a static method on the Convert class), but instead will returnString.Emptyif it is null.