Specialized classes for data storage and retrieval are collection classes. Support for stacks, queues, lists, and hash tables is given by these classes. The same interfaces are implemented by most collection types.
Collection classes serve various purposes, such as dynamically allocating memory to the elements and accessing an index-based list of objects, etc. These classes build object sets for the Object class, which is the base class for all C # data types.
Collection and delegate
public delegate void MyFirstDelgate(out int d);
static void Main(string args)
System.Collections.Stack stack = new System.Collections.Stack();
foreach (var item in stack)
System.Collections.ArrayList al = new System.Collections.ArrayList();
System.Collections.SortedList sl = new System.Collections.SortedList();
//MyFirstDelgate del = new MyFirstDelgate(One);
//del += Two;
public static void One(out int one)
one = 1;
public static void Two(out int two)
two = 2;
Collection classes and their uses-
This reflects an organised set of an item that can be separately indexed.
Essentially, it is an alternative to an array. However, unlike an array, an index can be used to add and remove items from a list at a specified position, and the array automatically resizes itself. It also allows the allocation, addition, search, and sorting of dynamic memory items in the list.
For accessing the elements in the array, it uses a key.
If you need to access elements using a key, a hash table is used, and you can define a useful key value. A key / value pair exists for each object in the hash table. The key is used in the collection to access the objects.
This reflects a last-in, first-out object set. It is used when you need to have access to things last-in, first-out. It is called moving an object when you add an object to the list, and when you delete it, it is called popping the item.
It represents a first-in, first-out object array. It is used when you need to view objects first-in, first-out. When you add an object to the list, it is called enqueue, and it is called deque when you delete an object.
This represents a binary representation sequence using the values 1 and 0. It is used when the bits need to be stored, but the number of bits in advance is not known. By using an integer index, which begins at zero, you can access items from the BitArray list.