关于c#:使用string.Empty的好处

Benefits of using string.Empty

本问题已经有最佳答案,请猛点这里访问。

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

为什么建议使用string.Empty而不是""?我从一方面理解,它使代码更清晰,没有"魔力常数"。使用string.Empty还有其他技术好处吗?谢谢。


Brad Abrams博客:

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…

这很微不足道。


我相信这已经被回答过了,但总的来说:偏好和可读性。

它们是完全等效的,并且取决于您和您的开发伙伴喜欢什么,只要保持一致即可。:)