Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fun with Lists for the Novice and Expert Scott Reed Brain Hz Software (760) 845-3320.

Similar presentations


Presentation on theme: "Fun with Lists for the Novice and Expert Scott Reed Brain Hz Software (760) 845-3320."— Presentation transcript:

1 Fun with Lists for the Novice and Expert Scott Reed Brain Hz Software (760)

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 – IEnumerator GetEnumerator() IEnumerator – bool MoveNext(); – 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 ObjectGenerics IEnumeratorIEnumerator (inherit non generics) ICollectionICollection (modifyable - more like IList) IListIList (adds random access) IDictionaryIDictionary (adds TryGetValue) ArrayListList (still an array) HashtableDictionary SortedList Queue, Stack LinkedList, and LinkedListNode

10 Extras FindAll Sort FxCop warnings BindingLists ObservableCollections DataTable yield

11 Thank You Scott Reed Brain Hz Software (760)


Download ppt "Fun with Lists for the Novice and Expert Scott Reed Brain Hz Software (760) 845-3320."

Similar presentations


Ads by Google