Recently, I've seen the following statement quite a lot:
object o;
// assign o
return "" + o;
(Basically the same as return String.Concat(o);)
Why would anyone want to do that? Why not just call .ToString() on the object (after checking object is not null, of course)?
Sure, the code is shorter and does away with the null check, but I find it confusing to read. Are there any other benefits to this? I've also seen the same statement with regard to integer values.
I expect to see above code in loosely typed languages such as JavaScript or PHP – but not in C#.