Mar 30, 2015

Generic vs Non-Generic Collection in C#

Non-Generic collections - These are the collections that can hold elements of different data types. It holds all elements as object type.
So it includes overhead of type conversions.

Generic collections - These are the collections that can hold data of same type and we can decide what type of data that collections can hold.

Some advantages of generic collections - Type Safe, Secure, reduced overhead of type conversions.

There are two distinct collection types in C#.

The standard collections, which are found under the System.Collections namespace and the generic collections, under System.Collections.Generic. Generic collections are more flexible and are the preferred way to work with data. The generic collections or generics were introduced in .NET framework 2.0. Generics enhance code reuse, type safety, and performance. 


No comments:

Post a Comment