difference between array and collection in .net

Posted by Shanky11 under C# on 1/31/2013 | Points: 10 | Views : 16814 | Status : [Member] | Replies : 2
difference between array and collection in .net?????????????????/
why array and collection is used ??????????????????
tell me in details?




Responses

Posted by: Sammy on: 1/31/2013 [Member] Starter | Points: 25

Up
0
Down
answer:

1) use an array when the number of elements that need to be inserted into the array is known at compile time and it remains fixed throughout the execution of the program. You use a collection when you do not know how many elements you will need to store. So basically a collection can grow in size dynamically. The data structure used to implement the collection depends on the collection type. e.g. for a Arraylist a doubly linked list may be used.

2) You can store elements of similar type only in an array. Unless ofcourse you declare an array of type 'Object'. In a collection you can store any type of elements provided they are all objects. You can store basic data types in an array. You can only store objects in a collection.

please mark this as answer if you find this interesting.

Regards
Samiran Chandra Bhuin

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kundan64 on: 1/31/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Shanky,
See the link: http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/bfc6cf96-1ef2-4383-8dda-eca0d99ac15f/

It will really help you.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response