"的String.Empty和&QUOT之间的差异; [英] difference between string.empty and ""

查看:132
本文介绍了"的String.Empty和&QUOT之间的差异;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/263191/in-c-should-i-use-string-empty-or-string-empty-or">In C#中,我应该使用的String.Empty或的String.Empty或ldquo;&rdquo;的?

有什么区别?

推荐答案

http://blogs.msdn.com/b/brada/archive/2003/04/22/49997.aspx

由于大卫暗示,有差异   的String.Empty和之间是pretty的   小,但有一个区别。   实际上创建了一个对象,它会   可能被拉出的字符串   实习生池,但仍...而   的String.Empty创建没有对象......所以,如果   你真正需要的最终   在内存效率,我建议   的String.Empty。然而,你应该   记住差异如此   繁琐你会喜欢永远看不到它   您的code ...

As David implies, there 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…

注意:

...你应该   记住差异如此   繁琐你会喜欢永远看不到它...

...you should keep in mind the difference is so trival you will like never see it...

这篇关于&QUOT;的String.Empty和&QUOT之间的差异;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆