473,748 Members | 6,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is the relationships between IList, Collection and Array

ad
Hi,
When I studied CSharp, I am confuse by IList, Collection and Array.
What is the relationships between them?
Nov 17 '05 #1
3 4216
IList is an interface. It provides a template, i.e. a common set of
properties and methods that every kind of list should implement. Any class
implementing IList must provide definitions for the members of this
interface. This guarantees that all classes that implement this interface
offer a basic set of common functionality. If you take a look at the
interface definition you will notice that IList implements two other
interfaces itself, namely ICollection and IEnumerable. This makes sense as a
list is basically an enumerable collection.

A collection is a term for a particular *kind* of class. The characteristics
that a collection should exhibit are defined in ICollection, and any data
structure implementing this interface is a collection. Simply think of a
collection as just that: a collection of objects (or simple data types, of
course).

An array *is* a collection. It shares some common features with all other
collections. However, it can be distinguished from other collections by its
specific functionality (e.g. it has a fixed size, it contains data of only
one type, etc.)

I hope this makes sense.
--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:eg******** ******@TK2MSFTN GP15.phx.gbl...
Hi,
When I studied CSharp, I am confuse by IList, Collection and Array.
What is the relationships between them?

Nov 17 '05 #2
Kai... A very thoughtful response, but I must admit that I cringe a
little bit when you describe an interface as a template. Another option
would be to describe an interface as a contract :) :) :).

http://www.geocities.com/jeff_louie/OOP/oop9.htm

When I see the word template in C# I think generics.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3
ad
Thank very much!

"Kai Brinkmann [MSFT]" <ka******@onlin e.microsoft.com > ¼¶¼g©ó¶l¥ó·s»D: uD************* *@tk2msftngp13. phx.gbl...
IList is an interface. It provides a template, i.e. a common set of
properties and methods that every kind of list should implement. Any class
implementing IList must provide definitions for the members of this
interface. This guarantees that all classes that implement this interface
offer a basic set of common functionality. If you take a look at the
interface definition you will notice that IList implements two other
interfaces itself, namely ICollection and IEnumerable. This makes sense as
a list is basically an enumerable collection.

A collection is a term for a particular *kind* of class. The
characteristics that a collection should exhibit are defined in
ICollection, and any data structure implementing this interface is a
collection. Simply think of a collection as just that: a collection of
objects (or simple data types, of course).

An array *is* a collection. It shares some common features with all other
collections. However, it can be distinguished from other collections by
its specific functionality (e.g. it has a fixed size, it contains data of
only one type, etc.)

I hope this makes sense.
--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no
rights.

"ad" <fl****@wfes.tc c.edu.tw> wrote in message
news:eg******** ******@TK2MSFTN GP15.phx.gbl...
Hi,
When I studied CSharp, I am confuse by IList, Collection and Array.
What is the relationships between them?


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2078
by: Sathyaish | last post by:
I wanted to practice some Linked List stuff, so I set out to create a linked list. The plan was to create the following: (1) A linked list class in Visual Basic (2) A non-class based linked list using functions in C (3) A linked list class in C++ I started with Visual Basic and I wrote an IList interface that I wanted my list to implement. When I had started, somehow I thought this time, I'd first use a collection as the ingredient,...
43
6885
by: Mountain Bikn' Guy | last post by:
I have a situation where an app writes data of various types (primitives and objects) into a single dimensional array of objects. (This array eventually becomes a row in a data table, but that's another story.) The data is written once and then read many times. Each primitive read requires unboxing. The data reads are critical to overall app performance. In the hopes of improving performance, we have tried to find a way to avoid the...
21
13843
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered by Sets. - ICollection cannot decide containment - IList promises indexability by the natural numbers, which is not achievable (since i hash elements, not sort them). - IDictionary is definatly not setlike. Although I can, of course, define...
3
4521
by: Giovanni Bassi | last post by:
Hello All, I have a class implementing IList and a global object of this class type. I have two different form objects. One has a ListBox and the other has ComboBox. Both of their datasources are set to this global object. The problem is that when I select an item in the ListBox the combobox selecteditem changes to the same item selected in the ListBox. And the oposite is also true, so when I select an item in the ComboBox my ListBox...
2
6965
by: Samuel R. Neff | last post by:
What's the advantage of inheriting from CollectionBase as opposed to just implementing IList? It seems that it saves you from having to implement a few properties (Clear, CopyTo, Count, GetEnumerator, and RemoveAt) but the way it implements all the other things you need to override seems overkill and counters the advantage of having an extensible base class. For example, the documentation example implementation of Remove: Public...
2
1384
by: fastfish | last post by:
I have a split db that on the dev versions w/ test data in the tables i have edited the relationships. Is there a way to move the relationships I have created in the dev db to the production db? thx chris
6
1542
by: Doug | last post by:
Hi, I want to create a collection of objects that will be used as a property of another object. So for example if I had a Customer object, I would like to have an AddressCollection property within that object. That AddressCollection property would contain one to many Addresses for each Customer and the Address object would have properties such as Street, City, State, etc. I am struggling with what interface to use to do this. I've...
2
4061
by: Paul | last post by:
I have two classes. One (FrontierApplication) is a definition of a record from a table. The other (FrontierApplicationCollection) is the collection of the first class. Below is how they are defined. I get an error when iterating through the collection. The error I get is "Unable to cast object of type 'ArrayListEnumeratorSimple' to type 'System.Collections.Generic.IEnumerator'" The error occurs in the collection class from the...
4
13164
by: forest demon | last post by:
I have an IList/Collection that contains items in a ListView. If i click on an item in the ListView, i can capture the index (lv.SelectedItems.Index) and reference the correct item in the associated IList/Collection . Once I've sorted the ListView, obviously the indices do not match up anymore. So, should i sort the IList/Collection when I sort the ListView (which seems overkill to me) or some how sort the indices associated with the...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.