Collection and Generics <>

2,288 views

Published on

Second Session about Collection and Generics @ IOM

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,288
On SlideShare
0
From Embeds
0
Number of Embeds
1,434
Actions
Shares
0
Downloads
69
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Collection and Generics <>

  1. 1. C# Collections &Generics <>Melick Rajee Baranasooriyahttp://melick-rajee.blogspot.com/
  2. 2. Collections ?• Classes for data storage and retrieval• Data can be storage using • Stacks • Queues • Lists • Hash tables • ..• Available under • System.Collections or System.Collections.Generic • ICollection, IComparer, IEnumerable, IList, IDictionary, and IDictionaryEnumerator
  3. 3. Collections• ArrayList • Not guaranteed to be sorted • Capacity of a ArrayList = Number of elements • Capacity will be increase when adding • Zero Base Index • Good for value types • Can use to pass parameters as well
  4. 4. Collections ..• BitArray • Use to store arrays of bits • True = 1 , False = 0;• Stack • LIFO • Methods • Pop • Push • Peek
  5. 5. Collections ..• SortedList • Element can be accessed by its key, • internally maintains two arrays to store the elements of the list • Sorting based on the key • Adding operation is slow but retrieval is faster• Queue • FIFO • Manage Sequence • Enqueue • Dequeue • Peek
  6. 6. Collections ..• Hashtable • presents a collection of key/value pairs • Access using key
  7. 7. Generic ?• Generic classes and methods combine reusability• Type Safe• Efficiency• Extend the behavior or Collection• Available in • System.Collections.Generic
  8. 8. Generic Data Structures• Stack<T>• List<T>• Queue<T>• KeyValuePair<TKey, TValue>• Dictionary<TKey, TValue>• Using Generic Methods and Expressions (lambda expressions) • Simple Types • Complex Types
  9. 9. Thank You.

×