Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2005, 10:31 AM
Authorized User
 
Join Date: Apr 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question on Collections/Arrays/ArrayList

Hi Friends,

I am learning C# and it is sort little confusing since I did some C++ programming. I have couple of questions regarding Collections,Array, ArrayList

1. What are collections? Is it just the namespace with an extensive set of classes or something is more to it?

2. What is ArrayList? How is it different from the Arrays? (In this aspect I am questioning myself with couple of questions and not finding answers so if you could answer them along with any more information, I am highly thankful.)
The basics questions are:
   a. you can declare an array of objects apart from array of value types so why do they need ArrayList
   b. does ArrayList provide some built-in methods that the coder has to codein if he uses array instead of ArrayList
   C. performance issues in case you use ArrayList instead of Array


Thankyou,
CsharpLearner
 
Old October 13th, 2005, 02:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

1. I am not completely sure about the semantics of collections, but AFAIK it was the old term used in VB for a container of objects, through which you can iterate using an enumeration. However, a collection is a broad term now (see link below). You can implement own collections using ICollection.

2. An ArrayList works in the same way as a linked list; or rather you have the same functionality; i.e. the size of the list is dynamic. Using an ordinary array you specify the size first and then use it. Using an ArrayList you can expand the structure later.

Performance-wise I don't know, however, I am pretty sure that ArrayLists are slower since you memory has to be allocated for each expansion of the list. With arrays memory are allocated once and for all when creating the array.

Take a look here. Quite good information on both ArrayList, ICollection etc....
http://msdn.microsoft.com/library/de...croottopic.asp

Hope it helps, Jacob.
 
Old October 13th, 2005, 06:05 PM
Authorized User
 
Join Date: Apr 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Jacob you are awesome....thank you:D





Similar Threads
Thread Thread Starter Forum Replies Last Post
collections help bennyt BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 July 26th, 2008 01:30 AM
Question about Arrays allbluegirl Beginning PHP 5 August 18th, 2003 06:47 PM
Collections question GregV VB.NET 2002/2003 Basics 0 August 6th, 2003 12:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.