The two are exactly identical once compiled. I find string.Empty
is more readable. For all we know ""
really should have something inside of it and it's just a typo.
Matt Greer
2010-08-20 20:44:39
The two are exactly identical once compiled. I find string.Empty
is more readable. For all we know ""
really should have something inside of it and it's just a typo.
Once the compiler gets done with that code, the IL/machine code for both fragments will be identical.
I tend to use string.Empty
when an empty string is an important part of the algorithm. I tend to use ""
for values that could be anything but for now it just happens to be an empty string. In other words, use the one that communicates the intent of the expression.
According to this MSDN blog post string.Empty
is more efficient as it will not produce a new object.
Here are some more information, including a short performance comparison.