This is third part of the 'LINQ' series articles that I have started from here. In this article, you will learn something about "Generic" collections such as what they are and why we need them in LINQ.
First of all let's understand what "Arrays" are, what ".NET Collections" are and what ".NET Generic Collections" are. You will see the following advantages and disadvantages in the examples given below.
| Collection Types | Advantages | Disadvantages |
| Arrays | Strongly Typed (Type Safe) |
|
| .NET Collections (like ArrayList, Hashtable etc) |
|
Not Strongly Typed |
| .NET Generic Collections (like List<T>, GenericList<T> etc) |
|
Now, let's discuss each of the collection types given in the above table to feel the real pain of development.
Array

If you use array:
- You can't enter more values beyond the initialized size otherwise you will see a runtime error saying "index was outside the bounds of the array".
- If you declare an array as an int type then, you are limited to enter integer values only otherwise you will see a compile time error saying "cannot implicitly convert type string to int", all because the array is type-safe.
- Array is index based, so you always need to write index number to insert value in collection.
- You don't have add and remove methods here.
ArrayList (System.Collection)

If you use ArrayList:
- You will get the auto grow feature, which means the initial size will not limit you.
- You don't have the option to declare the data type at declaration time initially, so you can add any value type like string, Boolean, int etc. Remember to care it in foreach loop at runtime.
- You will have some very useful methods like Remove, RemoveAt, RemoveRange etc. You don't however have any property like index.
List<T> (System.Collection.Generic)



Gowtham RajamanickamPosted Apr 11, 2015, 1:26 PM
good one
Gopesh SharmaPosted Sep 10, 2012, 5:34 AM
Nice article, it helps a lot...
Abhimanyu K VatsaPosted Sep 4, 2012, 12:03 AM
@Rushal: It means, restrictions on the intermixing that is permitted to occur, preventing the compiling or running of source code which uses data in what is considered to be an invalid way.
Rushal AroraPosted Sep 3, 2012, 8:29 PM
What is Strongly Typed (Type Safe) ?