<legend id='P4Dxz'><style id='P4Dxz'><dir id='P4Dxz'><q id='P4Dxz'></q></dir></style></legend>
    <tfoot id='P4Dxz'></tfoot>

      • <bdo id='P4Dxz'></bdo><ul id='P4Dxz'></ul>

      <small id='P4Dxz'></small><noframes id='P4Dxz'>

        <i id='P4Dxz'><tr id='P4Dxz'><dt id='P4Dxz'><q id='P4Dxz'><span id='P4Dxz'><b id='P4Dxz'><form id='P4Dxz'><ins id='P4Dxz'></ins><ul id='P4Dxz'></ul><sub id='P4Dxz'></sub></form><legend id='P4Dxz'></legend><bdo id='P4Dxz'><pre id='P4Dxz'><center id='P4Dxz'></center></pre></bdo></b><th id='P4Dxz'></th></span></q></dt></tr></i><div id='P4Dxz'><tfoot id='P4Dxz'></tfoot><dl id='P4Dxz'><fieldset id='P4Dxz'></fieldset></dl></div>

        在 C# 中,我应该使用 string.Empty 还是 String.Empty 还是“"?初始化一个字符串

        In C#, should I use string.Empty or String.Empty or quot;quot; to intitialize a string?(在 C# 中,我应该使用 string.Empty 还是 String.Empty 还是“?初始化一个字符串?)
          <i id='vv1AE'><tr id='vv1AE'><dt id='vv1AE'><q id='vv1AE'><span id='vv1AE'><b id='vv1AE'><form id='vv1AE'><ins id='vv1AE'></ins><ul id='vv1AE'></ul><sub id='vv1AE'></sub></form><legend id='vv1AE'></legend><bdo id='vv1AE'><pre id='vv1AE'><center id='vv1AE'></center></pre></bdo></b><th id='vv1AE'></th></span></q></dt></tr></i><div id='vv1AE'><tfoot id='vv1AE'></tfoot><dl id='vv1AE'><fieldset id='vv1AE'></fieldset></dl></div>

        • <legend id='vv1AE'><style id='vv1AE'><dir id='vv1AE'><q id='vv1AE'></q></dir></style></legend>

          <tfoot id='vv1AE'></tfoot>

              • <bdo id='vv1AE'></bdo><ul id='vv1AE'></ul>

                  <small id='vv1AE'></small><noframes id='vv1AE'>

                    <tbody id='vv1AE'></tbody>
                  本文介绍了在 C# 中,我应该使用 string.Empty 还是 String.Empty 还是“"?初始化一个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 C# 中,我想用一个空字符串初始化一个字符串值.

                  In C#, I want to initialize a string value with an empty string.

                  我应该怎么做?什么是正确的方法,为什么?

                  How should I do this? What is the right way, and why?

                  string willi = string.Empty;
                  

                  string willi = String.Empty;
                  

                  string willi = "";
                  

                  还是什么?

                  推荐答案

                  使用您和您的团队认为最易读的内容.

                  其他答案建议每次使用 "" 时都会创建一个新字符串.这不是真的 - 由于字符串实习,它将在每个程序集或每个 AppDomain 中创建一次(或者可能在整个过程中创建一次 - 在这方面不确定).这种差异可以忽略不计 - 非常大,非常微不足道.

                  Other answers have suggested that a new string is created every time you use "". This is not true - due to string interning, it will be created either once per assembly or once per AppDomain (or possibly once for the whole process - not sure on that front). This difference is negligible - massively, massively insignificant.

                  但是,您发现哪个更具可读性是另一回事.这是主观的,并且会因人而异——所以我建议你找出团队中大多数人喜欢的东西,然后为了保持一致.我个人觉得 "" 更容易阅读.

                  Which you find more readable is a different matter, however. It's subjective and will vary from person to person - so I suggest you find out what most people on your team like, and all go with that for consistency. Personally I find "" easier to read.

                  """ " 很容易被误认为是彼此的论点并没有真正与我擦肩而过.除非您使用的是比例字体(而且我没有与 任何 这样做的开发人员合作过),否则很容易区分.

                  The argument that "" and " " are easily mistaken for each other doesn't really wash with me. Unless you're using a proportional font (and I haven't worked with any developers who do) it's pretty easy to tell the difference.

                  这篇关于在 C# 中,我应该使用 string.Empty 还是 String.Empty 还是“"?初始化一个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                  • <bdo id='HDXf2'></bdo><ul id='HDXf2'></ul>

                        <tfoot id='HDXf2'></tfoot>

                          <i id='HDXf2'><tr id='HDXf2'><dt id='HDXf2'><q id='HDXf2'><span id='HDXf2'><b id='HDXf2'><form id='HDXf2'><ins id='HDXf2'></ins><ul id='HDXf2'></ul><sub id='HDXf2'></sub></form><legend id='HDXf2'></legend><bdo id='HDXf2'><pre id='HDXf2'><center id='HDXf2'></center></pre></bdo></b><th id='HDXf2'></th></span></q></dt></tr></i><div id='HDXf2'><tfoot id='HDXf2'></tfoot><dl id='HDXf2'><fieldset id='HDXf2'></fieldset></dl></div>

                          <small id='HDXf2'></small><noframes id='HDXf2'>

                          • <legend id='HDXf2'><style id='HDXf2'><dir id='HDXf2'><q id='HDXf2'></q></dir></style></legend>
                              <tbody id='HDXf2'></tbody>