0% found this document useful (0 votes)
52 views2 pages

COLLECTIONS IN C#

Uploaded by

Madhuri Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views2 pages

COLLECTIONS IN C#

Uploaded by

Madhuri Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COLLECTIONS IN C# PROGRAMMING

ARRAY COLLECTION
Cannot be resized at run-time. Can be resized at run-time.
The individual elements are of the The individual elements can be of
same data type. different data types.

Do not contain any methods for Contain methods for operations on


operations on elements. elements.

We can never insert a value into a We can insert a value into a middle of a
middle of an array. collection.

We can never delete a value from We can delete a value from a middle of
a middle of an array. a collection.

 A Collection is a set of related data that may not necessarily belong to the
same data type that can be set or modified dynamically at run-time.
 In other words, collection is a dynamic array.
o Its Length can increase on runtime. AUTO RESIZING
o
 Normal Array’s length is fixed, it means we cannot change the length after
declaring an array.
 Array.Resize()
 Resize method of an array destroys old array and create a new array with
new length.
 We can never insert a value into a middle of an array, because if we want to
do this then array length should be increased but we cannot increase the
length of an array after declaring the length of an array.
 We can never delete a value from a middle of an array.
 Accessing collections is similar to accessing arrays, where elements are
accessed by their index numbers. However, there are differences between
arrays and collections in C#.
 Collections were introduced in C# 1.0
 We have two kinds of Collections.
o Non-Generic collections
 Stack, ArrayList, Hashtable, SortedList etc.
 System.Collections namespace have non-generic
collections.
o Generic collections.
 List<T>, LinkedList<T>, Queue<T>,SortedList<T,V>.
 System.Collections.Generic namespace have generic
collections.

 COLLECTIONS HAVE A MECHANISM CALLED AUTO-RESIZING.


 CAPACITY PROPERTY WHICH TELLS NUMBER OF ITEMS THAT CAN BE STORED UNDER ANY
COLLECTION.
 INSERT METHOD.
 REMOVE AND REMOVEAT METHOD.

You might also like