object obj = "Hello"; string str1 = (string)obj; string str2 = obj.ToString();
What is the difference between (string)obj and obj.ToString()?
(string)obj
obj.ToString()
obj
string
ToString()
null
So in your specific case, both are equivalent.
Note that string is a reference type (as opposed to a value type). As such, it inherits from object and no boxing ever occurs.
1.4m articles
1.4m replys
5 comments
57.0k users