<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Compiler Error CS0165 使用了未賦值的局部變量“name” C# 編譯器不允許使用未初始化的變量。如果編譯器檢測到使用了可能未初始化的變量,就會生成 編譯錯誤CS0165。有關詳細信息,請參閱[字段(C# 編程指南)](https://msdn.microsoft.com/zh-cn/library/ms173118.aspx)。請注意,當編譯器遇到可能會導致使用未賦值變量的構造時,即使您的特定代碼不會使用該變量,也會生成此錯誤。這樣可以避免對明確賦值使用過度復雜的規則。 有關更多信息,請參見 [http://blogs.msdn.com/ericlippert/archive/2006/08/18/706398.aspx](http://blogs.msdn.com/ericlippert/archive/2006/08/18/706398.aspx)。 下面的示例生成 CS0165: ``` // CS0165.cs using System; class MyClass { public int i; } class MyClass2 { public static void Main(string[] args) { // i and j are not initialized. int i, j; // You can provide a value for args[0] in the 'Command line arguments' // text box on the Debug tab of the project Properties window. if (args[0] == "test") { i = 0; } // If the following else clause is absent, i might not be // initialized. //else //{ // i = 1; //} // Because i might not have been initialized, the following // line causes CS0165. j = i; // To resolve the error, uncomment the else clause of the previous // if statement, or initialize i when you declare it. // The following example causes CS0165 because myInstance is // declared but not instantiated. MyClass myInstance; // The following line causes the error. myInstance.i = 0; // To resolve the error, replace the previous declaration with // the following line. //MyClass myInstance = new MyClass(); } } ``` 編譯器錯誤 CS0165 在遞歸委托定義來生成。可以通過在以下兩個語句中定義委托可避免此錯誤,以便在變量初始化之前,不使用變量。下面的示例演示錯誤和解決方案。 ``` class Program { delegate void Del(); static void Main(string[] args) { // The following line causes CS0165 because variable d is used // as an argument before it has been initialized. Del d = delegate() { System.Console.WriteLine(d); }; //// To resolve the error, initialize d in a separate statement. //Del d = null; //// After d is initialized, you can use it as an argument. //d = delegate() { System.Console.WriteLine(d); }; //d(); } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看