- Back to Home »
- C#.NET »
- C#.NET Collections
Posted by :
Sudhir Chekuri
Sunday, 10 January 2016
Collections are used to store multiple values of object type. Memory for items is allocated dynamically and they can be accessed using indexes.
Collection classes are available under System.Collections namespace.
Types of collections are:
ArrayList
Stack
Queue
HashTable
Memory for items inside it is allocated and deallocated dynamically.
Indexes are used to access elements inside it.
Predefined methods of ArrayList are used to perform operations easily on ArrayList.
Memory is allocated dynamically for items in Stack and it accepts items of object type.
Indexes will not work for accessing items in Stack.
Push method is used to add items in Stack and it is known as pushing.
Pop method is used to remove items from Stack and it is known as popping.
Memory is allocated dynamically for items in Queue and it accepts items of object type.
Indexes will not work for accessing items in Queue.
Enqueue method is used to add items in Queue.
Dequeue method is used to remove items from Queue.
Elements in HashTable are accessed used key,
Each item in the HashTable has a key/value pair.
Using key the item value is accessed.
Collection classes are available under System.Collections namespace.
Types of collections are:
ArrayList
Stack
Queue
HashTable
ArrayList
It is used to store multiple values of object type. It is an alternative for array.Memory for items inside it is allocated and deallocated dynamically.
Indexes are used to access elements inside it.
Predefined methods of ArrayList are used to perform operations easily on ArrayList.
Stack
It follows a style of Last- In, First - out (LIFO) for inserting or removing elements from Stack Collections.Memory is allocated dynamically for items in Stack and it accepts items of object type.
Indexes will not work for accessing items in Stack.
Push method is used to add items in Stack and it is known as pushing.
Pop method is used to remove items from Stack and it is known as popping.
Queue
It follows a style of First- In, First - out (FIFO) for inserting or removing elements from Queue Collections.Memory is allocated dynamically for items in Queue and it accepts items of object type.
Indexes will not work for accessing items in Queue.
Enqueue method is used to add items in Queue.
Dequeue method is used to remove items from Queue.
HashTable
It uses a key to access the elements in the collection.Elements in HashTable are accessed used key,
Each item in the HashTable has a key/value pair.
Using key the item value is accessed.