Collection in .NET

Collection represents a set of objects that you can access by stepping through each element in turn
  • 2335
Introduction 

Collection represents a set of objects that you can access by stepping through each element in turn. The .NET Framework provides specialized classes for managing collection and these classes have rich capability for enhancing your programming experience through better performance and easy maintenance. A collection  sometimes called a container  is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve manipulate and communicate aggregate data.  A collection handle is what Shoplift uses to build a pretty looking search engine friendly web address also known as URL to your collection page on your store front. The .NET Base Class Library (BCL) has a wide array of collection classes at your disposal which make it easy to manage collections of objects. While it's great to have so many classes available it can be daunting to choose the right collection to use for any given situation. As hard as it may be choosing the right collection can be absolutely key to the performance and maintainability of your application.

Example

class Test
{
    static void Main()
    {
        StringCollection stringList = new StringCollection();
        stringList.Add("Manish");
        stringList.Add("Sandeep");
        stringList.Add("Amit");
        stringList.Add("Rajesh");
        foreach (string str in stringList)
        {
            Console.WriteLine(str);
        }
        Console.ReadLine();
    }
}

Output

ffffffffffffffffffffffffffff.gif    

 

  
© 2020 DotNetHeaven. All rights reserved.