473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

System.Array inherits from IList ???

Hi,

the specs for System.Array are :
MustInherit Public Class Array
Implements ICloneable, IList, ICollection, IEnumerable

but I can't use any of the functions presented by IList in my code
Dim numbers As System.Array
numbers.Add(1) --> NOT POSSIBLE Compiler error : 'System.Array'
does not contain a definition for 'Add'

nor some belonging to ICollection : SyncRoot:yes, Count:no
numbers.Count --> NOT POSSIBLE

IEnumerable : no problem

What is reasoning behind all this ?
Already does intelisense not show those functions. But why not ? if the
specs make you suppose you could use them.

Thanks in advance

Chris
Nov 20 '05 #1
2 2718
* "Chris" <ch********@pandora.be> scripsit:
the specs for System.Array are :
MustInherit Public Class Array
Implements ICloneable, IList, ICollection, IEnumerable

but I can't use any of the functions presented by IList in my code
Dim numbers As System.Array
numbers.Add(1) --> NOT POSSIBLE Compiler error : 'System.Array'
does not contain a definition for 'Add'

nor some belonging to ICollection : SyncRoot:yes, Count:no
numbers.Count --> NOT POSSIBLE

IEnumerable : no problem

What is reasoning behind all this ?
Already does intelisense not show those functions. But why not ? if the
specs make you suppose you could use them.


The interfaces are explicitly implemented (a feature, VB.NET doesn't
provide).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Herfried K. Wagner [MVP] wrote:
* "Chris" <ch********@pandora.be> scripsit:
the specs for System.Array are :
MustInherit Public Class Array
Implements ICloneable, IList, ICollection,
IEnumerable

but I can't use any of the functions presented by IList in my code
Dim numbers As System.Array
numbers.Add(1) --> NOT POSSIBLE Compiler error :
'System.Array' does not contain a definition for 'Add'

nor some belonging to ICollection : SyncRoot:yes, Count:no
numbers.Count --> NOT POSSIBLE

IEnumerable : no problem

What is reasoning behind all this ?
Already does intelisense not show those functions. But why not ? if
the specs make you suppose you could use them.
The interfaces are explicitly implemented (a feature, VB.NET doesn't
provide).


No, they just haven't made the methods public on the class, (the default
interface in VB6/COM speak) or not with the same name.

Eg. Array.Length Implements ICollection.Count

(Proof:
With GetType(System.Array)
System.Console.WriteLine( _
.GetMethod("Length") _
Is .GetMethod("Count", New System.Type() _
{GetType(System.Collections.ICollection)}))
End With

displays True.(*))

BTW IList.Add on an Array always fails with System.NotSupportedException,
message: Collection was of a fixed size.
--
Regards,
Mark Hurd, B.Sc.(Ma.) (Hons.)
(*) That looks convoluted enough to just use ILDASM and determine it from
there, but it's acually my (tested) conversion from this DotLisp test: (eql? (.GetMethod Array. "Length")(.GetMethod Array. "Count"

[ICollection.]))
True

Nov 20 '05 #3

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

Similar topics

2
by: tsteinke | last post by:
I noticed somthing. The native Array Types implement the IList interface. However they do not contain all the methods in the interfaces they implement. for example... int test=new int;...
4
by: emma middlebrook | last post by:
Hi Straight to the point - I don't understand why System.Array derives from IList (given the methods/properties actually on IList). When designing an interface you specify a contract. Deriving...
3
by: Chris | last post by:
Hi, the specs for System.Array are : public abstract class Array : ICloneable, IList, ICollection, IEnumerable but I can't use any of the functions presented by IList in my code ...
3
by: ad | last post by:
Hi, When I studied CSharp, I am confuse by IList, Collection and Array. What is the relationships between them?
4
by: Jim Shaffer | last post by:
Perhaps I have the wrong construct, or misunderstand arrays in vb (2003).... I've loaded a two-dimensional array (168 by 28) into memory as AcctArray. {Dim AcctArray (500,28) as string...} The...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
4
by: kin | last post by:
After a I read Walkthrough: Connecting to Data in Objects (http://msdn2.microsoft.com/en-us/library/ms171892.aspx#Mtps_DropDownFilterText). I still have project on that. My School project...
6
by: Arthur Dent | last post by:
How do you sort a generic collection derived from System.Collections.ObjectModel.Collection? Thanks in advance, - Arthur Dent
0
by: Martin Henke | last post by:
Dear all, I've got a problem with my custom combo box. When I select an entry from it, then I get the error message: "An unhandled exception of type 'System.ArgumentOutOfRangeException'...
2
by: Tony Johansson | last post by:
Hello! The Array class implements these interfaces IClonable, IList, ICollection and IEnumerable. Note only interfaces are inherited and no classes so these interfaces will be implemented in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.