By a *very* small margin, the first. The second compiles to
string.Concat(obj) [note that the + "" is optimised away]. This is an
additional method call (which is possibly inlined), but which does an
additional null check (returning "" if obj is null) before calling the
same obj.ToString().
The difference will be stupidly small, and is unlikely to *ever* show
on any performance trace - so go with whichever is simplest to read.
For me, the first wins this. Note that they behave differently for obj
= null, though.
Also, it's better from a maintainability perspective. The first code
does exactly what it says, nothing more and nothing less. The second
code describes a nonsense-operation that only has the purpose of causing
an implicit conversion.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.