《MCTS.C#》(part.5)第六章:陣列、集合、泛型 Array,ArrayList,List<>

  •  Array 陣列
    •  Array.Sort(arrayobject)
    •  Array.IndexOf(arrayobject,findValue)
    •  Array.Copy(sourceArray,toArray,copylength)
    •  Length :取長度
  •  ArrayList 陣列集合
    •  Count:取長度
    •  Add:新增項目,…
    •  var 抓不到型別
    •  C# 3.0 後,可支援集合初始設定式(collection initialize):ArrayList al = new ArrayList() {100,”Bruce”,DateTime.Now};
  •  集合因為使用Object存取所以會有:
    •  容易發生轉型失敗的例外狀況
    •  boxing/unboxing
      •  value type 轉為 object才會有boxing的問題
      •  reference type則不會有boxing的問題
      •  boxing : value type -> object (由stack 轉至 heap)
      •  unboxing: object-> value type (由heap 轉stack)

 

collection Generic
ArrayList List<T>
HashTable Dictionary<TKey,TValue>
  •  泛型
    • List<T>
    • Dictionary<TKey,TValue>

 

Tagged with:     , , , ,

About the author /


Hi,我是露露,喜歡登山,雖然很肉腳但是還是想挑戰百岳。 喜歡程式設計,雖然沒有非常的強,但是還是都可以完美的完成。

Post your comments

Your email address will not be published. Required fields are marked *

正在載入中...