Skip to main content

Posts

Showing posts with the label Collections

Dictionaries in .Net

Namespace: System.Collections Dictionaries are meant to store data in Key/Value pair. Dictionary class supports the Key/Value pair collection. Most basic Implementation is HashTable . HashTable h = new HashTable(); h.add(“mubbasher@ymail.com”, “Mubbasher Mukhtar”); h[“mubbasher@ymail.com”] = “Mukhtar, Mubbasher”; Console.WriteLine(h[“mubbasher@ymail.com”]); To iterate items in Dictionary: foreach(DictionaryEntery entry in h)                 Console.WriteLine( entry.Value); All Dictionary classes inherit from IDictionary interface. And intern IDictionary interface inherits from ICollection Interface. Inheritance Sequence : IEnumerator  ⇨ IEnumerable ⇨ ICollection ⇨ IDictionary Important properties of the IDictionary interface: Name Description Count Gets the number of elements contained in the ICollection. (Inherited from I...

Sequential Lists in .Net

Namespace: System.Collections Queue Class: It’s a First-in, First-out (FIFO) structure. Important Properties includes Count . Important Methods include Dequeue , Enqueue , and Peek . Stack Class: It’s a Last-in, First-out (LIFO) structure. Important Properties includes Count . Important Methods include Pop , Push , and Peek .

Collections in .Net

Namespace: System.Collections Types of Collections: Class Description ArrayList Implements the IList interface using an array whose size is dynamically increased as required. BitArray Manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0). CaseInsensitiveComparer Compares two objects for equivalence, ignoring the case of strings. CaseInsensitiveHashCodeProvider Obsolete. Supplies a hash code for an object, using a hashing algorithm that ignores the case of strings. CollectionBase Provides the abstract base class for a strongly typed collection. Comparer Compares two objects for equivalence, where string comparisons are case-sensitive. DictionaryBase Provides the abstract base class for a strongly typed collection of key/value pairs. Hashtable...