0

Possible Duplicate:
What is the difference between String.Empty and “”

Why it is recommended to use string.Empty instead of ""? From one side, I understand, that it makes code clearer, without "Magic constants". Is there any another technical benefits of using string.Empty?
Thanks.

Community
  • 1
  • 1
Sergey Metlov
  • 25,747
  • 28
  • 93
  • 153
  • 3
    and: http://stackoverflow.com/questions/263191/in-c-should-i-use-string-empty-or-string-empty-or – Joe Aug 08 '11 at 19:55

2 Answers2

4

Per Brad Abrams blog:

the difference between String.Empty and “” are pretty small, but there is a difference. “” actually creates an object, it will likely be pulled out of the string intern pool, but still… while String.Empty creates no object… so if you are really looking for ultimately in memory efficiency, I suggest String.Empty. However, you should keep in mind the difference is so trival you will like never see it in your code…

It's pretty insignificant.

David Hoerster
  • 28,421
  • 8
  • 67
  • 102
3

I believe this has been answered before, but to summarize: preference and readability.

They are completely equivalent, and are up to whatever you and your fellow developers prefer, just be consistent. :)

Rion Williams
  • 74,820
  • 37
  • 200
  • 327