.NETGURU
Array.IList implementation
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.sdk.

Post a new message to this list...

A J Le Couteur Bisson
I am very confused with the Array.IList implementation. All of the methods
are private which hardly seems to be fulfilling the IList contract... If I
cast an array then IList methods (e.g. Contains()) work correctly for arrays
of rank 1. Where is the code that check the rank of arrays and
allows/disallows IList.Contains() accordingly? I am using Reflector to
examine the framework code and I cannot find this functionality. Any clues?

Thanks,
Andy

Reply to this message...
 
    
Dot Net Guruias Sjögren
[Original message clipped]

Why not? Interfaces don't specify which accessibility the implementing
method must have - private is fine.

[Original message clipped]

Array::System.Collections.IList.Contains(object) calls
Array::IndexOf(Array, object), which in turn calls
Array::IndexOf(Array, object, int, int). There you'll find code that
checks the Rank and throws an exception if it's != 1.

Dot Net Guruias

--
Dot Net Guruias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Reply to this message...
 
    
A J Le Couteur Bisson
"Dot Net Guruias Sjögren" <Click here to reveal e-mail address> wrote in message
news:#Click here to reveal e-mail address...
[Original message clipped]

Thanks for the prompt response. Clearly the contract offered by interfaces
*can* be rather less useful than I supposed. (I am reminded of a past
employer
which, under contract to make 'a delivery', delivered an empty box!**)

I am still puzzled as to why these methods are private. What harm could
result
from making them public?

if((myArray as IList).Contains(3))

doesn't seem any clearer or more appropriate than

if(myArray.Contains(3))

Thanks,
Andy

** A very large company that ought to know better...

Reply to this message...
 
    
Dot Net Guruias Sjögren
Andy,

[Original message clipped]

I don't know why they decided to implement IList privately. Perhaps
because the interface is only partially supported (the Add, Insert,
Remove and RemoveAt methods will throw).

Dot Net Guruias

--
Dot Net Guruias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Reply to this message...
 
 
System.Array
System.Collections.IList




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification