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

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

        <legend id='N5sAf'><style id='N5sAf'><dir id='N5sAf'><q id='N5sAf'></q></dir></style></legend>
      1. <tfoot id='N5sAf'></tfoot>

        C# 变量初始化问题

        C# Variable Initialization Question(C# 变量初始化问题)
            <tbody id='g8nxV'></tbody>
            <tfoot id='g8nxV'></tfoot>

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

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

                  本文介绍了C# 变量初始化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是否初始化一个整数变量有什么区别:

                  Is there any difference on whether I initialize an integer variable like:

                  int i = 0;
                  int i;
                  

                  编译器或 CLR 是否将其视为同一件事?IIRC,我认为它们都被视为同一个东西,但我似乎找不到这篇文章.

                  Does the compiler or CLR treat this as the same thing? IIRC, I think they're both treated as the same thing, but I can't seem to find the article.

                  推荐答案

                  我查看了IL(使用ildasm),确实只有设置为0的int在构造函数中真正设置为0.

                  I looked at the IL (using ildasm) and its true that only the int set to 0 is really set to 0 in the constructor.

                  public class Class1
                  {
                      int setToZero = 0;
                      int notSet;
                  }
                  

                  生成:

                  .method public hidebysig specialname rtspecialname 
                          instance void  .ctor() cil managed
                  {
                    // Code size       15 (0xf)
                    .maxstack  8
                    IL_0000:  ldarg.0
                    IL_0001:  ldc.i4.0
                    IL_0002:  stfld      int32 ClassLibrary1.Class1::setToZero
                    IL_0007:  ldarg.0
                    IL_0008:  call       instance void [mscorlib]System.Object::.ctor()
                    IL_000d:  nop
                    IL_000e:  ret
                  } // end of method Class1::.ctor
                  

                  这篇关于C# 变量初始化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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() 和泛型:错误绑定到目标方法)
                  <tfoot id='8cAvt'></tfoot>
                      <tbody id='8cAvt'></tbody>

                    <small id='8cAvt'></small><noframes id='8cAvt'>

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

                      • <bdo id='8cAvt'></bdo><ul id='8cAvt'></ul>

                        • <legend id='8cAvt'><style id='8cAvt'><dir id='8cAvt'><q id='8cAvt'></q></dir></style></legend>