I know its too late to comment on this question but I think many people have the similar doubt about (string)object
and object.ToString()
and this question is the correct place to comment on.
When its sure that the type of object is string then its better to do a typecasting
rather than calling a method .ToString()
. If you look into the code of ToString()
:
public virtual string ToString()
{
return this.GetType().ToString();
}
Which is first finding the type of object by calling GetType()
method then calling the ToString()
of that type.
If we are not sure about the type of object
then the answer would be do ToString()
instead of (string)
.
If you wanted to see the benchmark of performance of (string) vs .ToString() then follow the link : (string) vs .ToString()