Topic : Collection in C# Programming - Generic Classes | Concurrent Classes | Non-Generic Classes.

Collections:

For Many Applications, we want to create and manage groups of related objects. there are two ways to group Objects.



Arrays are most Useful for creating and working with a fixed number of strongly-typed Objects. But Collections provide a more flexible way to work with groups of Objects. Array has size limit but Objects stored in Collection can grow and shrink dynamically as the need of the application change.



  • Type of Collections in C#:

    Collection Classes Are specialized classes for data storage and Retrieval. These classes serve various purpose, such as Allocation memory Dynamically to elements and accessing a list of items on the basis of an index etc. .NET Framework provide many common Collections and each collection is designed for a specific purpose. some of the common collection classes are:

    » System.Collection.Generic Classes - (Generic Collection)
    » System.Collections Classes - (Non-Generic Collection).
    » System.Collections.Concurrent Classes. (Read more...)



System.Collections.Generic Classes.

A generic Collection is useful when every item in the Collection has the same data type. A Generic Collection enforces strong type by Allowing only the Desired data type to be added. Generic Collection is Strongly type Collection, which mean that we can put only one type of Object into it. This eliminates type mismatches at runtime.

The following are the various commonly used classes of the System.Collection.Generic Namespace. Click the Following links to check their detail.





System.Collections Classes.

It is Non-Generic Collection, and it is useful when we have different type of item in Collection. In this collection, Each Element Can Represent a Value of a Different type. The Array size is not fixed and Elements can be added or removed at runtime. The classes in the System.Collections namespace do not store elements as specifically typed objects, but as objects of type Object.



Whenever possible, we should use the Generic Collections in the System.Collections.Generic namespace or the System.Collections.Concurrent namespace instead of the legacy types in the System.Collections namespace.


The following are the various commonly used classes of the System.Collection Namespace. Click the Following links to check their detail.





System.Collections.Concurrent Classes.

System.Collections.Concurrent Namespace provide efficient thread-safe Operations for accessing collection items from Multiple threads. The Class in the System.Collections.Concurrent Namespace should be used instead of the corresponding types in the System.Collections.Generic and System.Collections namespaces whenever multiples thread are accessing the collection concurrently. (Read more...)



IN C#, Collection Represents group of Objects. By the help of Collections, we can perform various Operations on Object such as, Update Object, delete object, retrieve Object, search Object and sort object.in Short, all the data structure work can be performed by C# Collections.

















I Tried my Best to Provide you complete Information regarding this topic in very easy and conceptual way. but still if you have any Problem to understand this topic, or do you have any Questions, Feel Free to Ask Question. i'll do my best to Provide you what you need.

Sardar Omar.
InfoBrother





WRITE FOR INFOBROTHER

Advertising






Advertisement