新聞中心
C# 泛型和數(shù)組在 C# 2.0 中,下限為零的一維數(shù)組自動實現(xiàn) IList

成都創(chuàng)新互聯(lián)成立于2013年,先為盧龍等服務(wù)建站,盧龍等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為盧龍企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
C# 泛型和數(shù)組代碼
- class Program
- {
- static void Main()
- {
- int[] arr = { 0, 1, 2, 3, 4 };
- List
list = new List (); - for (int x = 5; x < 10; x++)
- {
- list.Add(x);
- }
- ProcessItems
(arr); - ProcessItems
(list); - }
- static void ProcessItems
(IList coll) - {
- foreach (T item in coll)
- {
- System.Console.Write(item.ToString() + " ");
- }
- System.Console.WriteLine();
- }
- }
C# 泛型和數(shù)組應(yīng)用時注意
盡管 ProcessItems 方法無法添加或移除項,但對于 ProcessItems 內(nèi)部的 T[],IsReadOnly 屬性返回 False,因為該數(shù)組本身未聲明 ReadOnly 特性。
C# 泛型和數(shù)組的相關(guān)內(nèi)容就向你介紹到這里,希望對你了解和學(xué)習(xí)C# 泛型和數(shù)組有所幫助。
網(wǎng)站欄目:C#泛型數(shù)組學(xué)習(xí)小結(jié)
網(wǎng)頁地址:http://m.5511xx.com/article/cdjescp.html


咨詢
建站咨詢
