Home > DeveloperSection > Blogs > Introduction to Collection Framework in c#

Introduction to Collection Framework in c#

C# C# 
0 Comment(s)
 2022  View(s)
Rate this:

Introduction to Collection Framework in C#

Collections are providing a more flexibility to work with groups of objects. Unlike in array, you don’t use a dynamically i.e. fixed number of strongly- typed objects.


A collections is a set of similarly type of elements that are grouped together System.Collection namespace contains interfaces and classes that define various collections of objects, such as lists, queue, hash tables and dictionaries, and so on. 


If you want to define collection class that can work with only one data type then you can use one of the class in the System.Collections.Generic namespace. You can’t added other data type that provide enforces type safety. If you are working with generic collection then you don’t need to determine its data type or conversion.

Using a simple Collection:

Using a simple collection, we can define collection as a strongly typed i.e. single data type are as follow:


The following example are using collection  for creating a list of strings and then iterates all elements in the list by using a foreach statement in C#.


// Create a list of strings.

// var listex = new List<string> {“Apple", "Mango", "Banana", "Papaya”};

var listex = new List<string>();






// Iterate through the list.

foreach (var pr in listex)


    Console.Write(pr + " ");


// Output: Apple Mango Banana Papaya             

Don't want to miss updates? Please click the below button!

Follow MindStick