Possible Duplicate:
In C#, should I use string.Empty or String.Empty or “” ?
Is it better to
return string.Empty;
instead of
return "";
What do you think?
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.
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.
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.