ToString is a method defined in the Object class, which is then inherited in each class in the entire structure.
The ToString method in the String class has been overwritten by an implementation that simply returns itself. Thus, there is no overhead when calling ToString () on a String object.
So, I don’t think to worry about anything.
In addition, I would go with the first option. This is more readable, and you should always get the result, regardless of the type of "obj".
source share