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

成都創(chuàng)新互聯(lián)成立于2013年,先為盧龍等服務(wù)建站,盧龍等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為盧龍企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。
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)用時(shí)注意
盡管 ProcessItems 方法無(wú)法添加或移除項(xiàng),但對(duì)于 ProcessItems 內(nèi)部的 T[],IsReadOnly 屬性返回 False,因?yàn)樵摂?shù)組本身未聲明 ReadOnly 特性。
C# 泛型和數(shù)組的相關(guān)內(nèi)容就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C# 泛型和數(shù)組有所幫助。
分享題目:C#泛型數(shù)組學(xué)習(xí)小結(jié)
文章URL:http://www.fisionsoft.com.cn/article/cdjescp.html


咨詢
建站咨詢
