<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之旅 廣告
                # 泛型和數組(C# 編程指南) 在 C# 2.0 以及更高版本中,下限為零的一維數組自動實現 [IList&lt;T&gt;](https://msdn.microsoft.com/zh-cn/library/5y536ey6.aspx)。這使您可以創建能夠使用相同代碼循環訪問數組和其他集合類型的泛型方法。此技術主要對讀取集合中的數據很有用。 [IList&lt;T&gt;](https://msdn.microsoft.com/zh-cn/library/5y536ey6.aspx) 接口不能用于在數組中添加或移除元素。如果嘗試對此上下文中的數組調用 [IList&lt;T&gt;](https://msdn.microsoft.com/zh-cn/library/5y536ey6.aspx) 方法(例如 [RemoveAt](https://msdn.microsoft.com/zh-cn/library/c93ab5c9.aspx)),則將引發異常。 下面的代碼示例演示帶有 [IList&lt;T&gt;](https://msdn.microsoft.com/zh-cn/library/5y536ey6.aspx) 輸入參數的單個泛型方法如何同時循環訪問列表和數組,本例中為整數數組。 ``` class Program { static void Main() { int[] arr = { 0, 1, 2, 3, 4 }; List<int> list = new List<int>(); for (int x = 5; x < 10; x++) { list.Add(x); } ProcessItems<int>(arr); ProcessItems<int>(list); } static void ProcessItems<T>(IList<T> coll) { // IsReadOnly returns True for the array and False for the List. System.Console.WriteLine ("IsReadOnly returns {0} for this collection.", coll.IsReadOnly); // The following statement causes a run-time exception for the // array, but not for the List. //coll.RemoveAt(4); foreach (T item in coll) { System.Console.Write(item.ToString() + " "); } System.Console.WriteLine(); } } ``` ## 請參閱 [System.Collections.Generic](https://msdn.microsoft.com/zh-cn/library/system.collections.generic.aspx) [C# 編程指南](https://msdn.microsoft.com/zh-cn/library/67ef8sbd.aspx) [泛型(C# 編程指南)](https://msdn.microsoft.com/zh-cn/library/512aeb7t.aspx) [數組(C# 編程指南)](https://msdn.microsoft.com/zh-cn/library/9b9dty7d.aspx) [.NET Framework 中的泛型](https://msdn.microsoft.com/zh-cn/library/ms172192.aspx)
                  <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>

                              哎呀哎呀视频在线观看