1 / 11

Fun with Lists for the Novice and Expert

Fun with Lists for the Novice and Expert. Scott Reed Brain Hz Software scott@brainhzsoftware.com (760) 845-3320. In the beginning…. There were arrays… And there were System.Collections ArrayList : IList : ICollection : IEnumerable Hashtable : IDictionary : ICollection …

torn
Download Presentation

Fun with Lists for the Novice and Expert

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fun with Listsfor the Novice and Expert Scott Reed Brain Hz Software scott@brainhzsoftware.com (760) 845-3320

  2. In the beginning… • There were arrays… • And there were System.Collections • ArrayList : IList : ICollection : IEnumerable • Hashtable : IDictionary : ICollection … • Various others • Queue, Stack, SortedList

  3. IEnumerable and IEnumerator • Pull style iteration (better than Java :) • IEnumerable • IEnumeratorGetEnumerator() • IEnumerator • boolMoveNext(); • object Current { get; } • What foreach uses • foreach (object item in arrayList)

  4. ICollection • Count • CopyTo • SyncRoot and IsSynchronized*

  5. IList • Adding and removal • Add, Insert, Remove, RemoveAt • Clearing (via Clear) • Random access • has an indexer • Finding • Contains, IndexOf • Properties • IsFixedSize, IsReadOnly

  6. IDictionary • Adding and removal • Add, Remove and Clear only • Random access • has an indexer • Finding • Contains only • Properties • IsFixedSize, IsReadOnly • Collections • Keys and Values

  7. Side note: What about Arrays? • int[] : Array : IList : ICollection : IEnumerable • Fixed size collections • Add and Remove not supported

  8. What is the problem? • Dangerous - Type safety • Ugly - Casting • Performance of value types (boxing and unboxing)

  9. System.Collections.Generic

  10. Extras • FindAll • Sort • FxCopwarnings • BindingLists • ObservableCollections • DataTable • yield

  11. Thank You Scott Reed Brain Hz Software scott@brainhzsoftware.com (760) 845-3320

More Related