<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 CS1579 foreach 語句不能對“type1”類型的變量進行操作,因為“type2”不包含“identifier”的公共定義 若要使用 [foreach](https://msdn.microsoft.com/zh-cn/library/ttw7t8t6.aspx) 語句循環訪問某個集合,該集合必須滿足以下要求: * 它必須是一個接口、類或結構。 * 它必須包含一個返回類型的公共 [GetEnumerator](https://msdn.microsoft.com/zh-cn/library/system.collections.ienumerable.getenumerator.aspx) 方法。 * 返回類型必須包含一個名為 [Current](https://msdn.microsoft.com/zh-cn/library/system.collections.ienumerator.current.aspx) 的公共屬性和一個名為 [MoveNext](https://msdn.microsoft.com/zh-cn/library/system.collections.ienumerator.movenext.aspx) 的公共方法。 * 有關更多信息,請參見 [如何:使用 foreach 訪問集合類(C# 編程指南)](https://msdn.microsoft.com/zh-cn/library/9yb8xew9.aspx)。 在本示例中,[foreach](https://msdn.microsoft.com/zh-cn/library/ttw7t8t6.aspx) 無法循環訪問集合,因為 MyCollection 集合中沒有 **public**[GetEnumerator](https://msdn.microsoft.com/zh-cn/library/system.collections.ienumerable.getenumerator.aspx) 方法。 下面的示例生成 CS1579。 ``` // CS1579.cs using System; public class MyCollection { int[] items; public MyCollection() { items = new int[5] {12, 44, 33, 2, 50}; } // Delete the following line to resolve. MyEnumerator GetEnumerator() // Uncomment the following line to resolve: // public MyEnumerator GetEnumerator() { return new MyEnumerator(this); } // Declare the enumerator class: public class MyEnumerator { int nIndex; MyCollection collection; public MyEnumerator(MyCollection coll) { collection = coll; nIndex = -1; } public bool MoveNext() { nIndex++; return(nIndex < collection.items.GetLength(0)); } public int Current { get { return(collection.items[nIndex]); } } } public static void Main() { MyCollection col = new MyCollection(); Console.WriteLine("Values in the collection are:"); foreach (int i in col) // CS1579 { Console.WriteLine(i); } } } ```
                  <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>

                              哎呀哎呀视频在线观看