array count error

Class library usage, coding and language questions.
omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

array count error

Post by omayer » Thu Oct 04, 2012 4:46 pm

getting the followin gerror when counting the element in arrray -

Code: Select all

int countArrayElement = GlobalVarClass.errorScnid.Count;
'System.Array' does not contain a definition for 'Count' and no extension method 'Count' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?) (CS1061) -
Tipu

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: array count error

Post by omayer » Thu Oct 04, 2012 4:47 pm

problem fixed by adding reference - using System.Collections;
Tipu

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: array count error

Post by omayer » Thu Oct 04, 2012 5:01 pm

NOT fixed , same error returned after adding system.collections, Thank you in advance
Tipu

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: array count error

Post by sdaly » Fri Oct 05, 2012 7:52 am

As the error states, the Array type does not contain a member called Count (collections do)... Use Length when dealing with Arrays -

http://msdn.microsoft.com/en-us/library ... array.aspx

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: array count error

Post by omayer » Wed Oct 10, 2012 9:17 pm

thank you sdaly, it worked w/length
Tipu