Both converts the specified value to its equivalent String representation.
Convert.Tostring handles null value and returns string.Empty.
But Tostring doesn't handle null value and throws a NullReferenceException.
object obj = null;
string b = Convert.ToString(obj); //value of b will be ""
string a = obj.ToString(); // throws NullReferenceException
Convert.Tostring handles null value and returns string.Empty.
But Tostring doesn't handle null value and throws a NullReferenceException.
object obj = null;
string b = Convert.ToString(obj); //value of b will be ""
string a = obj.ToString(); // throws NullReferenceException
No comments:
Post a Comment