Lets say we have the folowing code.
var foo = "I am a string";
Object obj = foo;
var bar = obj.ToString();
What is actually happening?
- Cast the obj to a string and then calls the ToString Method?
- Calls the ToString method on obj which is the override of string without casting?
- Something else?
Witch one is better to do?
var bar = obj.ToString();
var bar = (string)obj;