I think you'll find that the extension method will try to cast the array to ICollection and call it's .Count property (which it does have but it's an explicit implementation). That property will in turn just call .Length. It's a roundabout way of doing it but it means that it's not enumerating the collection and adding 1 for each item to get the result.
-- Michael M. Minutillo Indiscriminate Information Sponge Blog: http://wolfbyte-net.blogspot.com On Tue, Feb 15, 2011 at 1:23 PM, Ian Thomas <[email protected]> wrote: > Michael – slip of the fingers – yes, it was a .Count method (when LINQ is > referenced), and a .Length property (when not). Not weird, lang c# > > > ------------------------------ > > Ian Thomas > Victoria Park, Western Australia > ------------------------------ > > *From:* [email protected] [mailto: > [email protected]] *On Behalf Of *Michael Minutillo > *Sent:* Tuesday, February 15, 2011 1:20 PM > *To:* ozDotNet > *Subject:* Re: LINQ extensions > > > > Weird. It should add a .Count() extension method, not a property. Are you > coding in a language that has optional parentheses by any chance? > > On Tue, Feb 15, 2011 at 1:12 PM, Ian Thomas <[email protected]> > wrote: > > FYI only > > Just an oddity I hadn’t taken in before, that a reference to LINQ makes > .Count a valid property of arrays (otherwise .Length is valid). > > I had been using LINQ to Objects in a small projects and changed it to not > do so, meticulously cleaned references to LINQ out (VS2008 does not seem to > do that thoroughly), and had a couple of errors arise with myarrays.Count > statements I had been slack enough to write previously. > > Framework 3.5 > ------------------------------ > > Ian Thomas > Victoria Park, Western Australia > > >
