Difference between Convert.ToString() and object.ToString()
Interview question and answer by:
Rajni.Shekhar | Posted on: 3/19/2012 | Category:
ASP.NET Interview questions | Views: 1820 | |
Points: 40
Answer:
object.ToString() give run time error if object value is null, whereas Convert.ToString(object) does not give any error in case of object value is null;
Example:
object obj=null;
string str=obj.ToTsirng(); //it will give run time error
string str1=Convert.ToString(obj); // it will run, not give any error
Asked In: Many Interviews
|
Alert Moderator
Found interesting? Add this to: