views:

1087

answers:

2

I'm trying to access the Count Property on the array of rows returned by the datatables select method, this is after converting the Web Project to 3.5

+3  A: 

Use .Length instead.

Joel Coehoorn
ok but the codebase already uses .count in alot of places and was originally working.... am I missing a reference or something
keyoke
Odd.. arrays have never had a .Count property. I wonder if that used to be a 'hack' in the system that they had to remove to avoid conflicted with IEnumerable.count
Joel Coehoorn
in msdn when looking at the System.Array members/properties if you select 2.0 as the framework there is no count property but if you select 3.5 it appears.
keyoke
Because arrays implement IEnumerable, and in 3.5 IEnumerable and .Count extension.
Joel Coehoorn
And you don't want to rely on that, because it means actually iterating over the array and counting the elements, rather than just looking it up.
Joel Coehoorn
Just remember that .Length is 0-based and .Count is 1-based. If an Array contains [Steve|Tom|George] then .Length() will return 2 and .Count() will return 3.
STW
@Yooder that's wrong.
Joel Coehoorn
A: 

I was missing <add namespace="System.Linq"/> from my web.config

keyoke