I am trying to do a simple count of some descendants using LINQ to XML and the “Count()” method does not exist for me?
Example:
using System.Xml.Linq;
XDocument doc = XDocument.Load( "somexmlfile" );
int count = doc.Descendants("somethinghere").Count();
The above won’t compile, because it doesn’t recognize the Count() method.
Do you have
using System.Linq;at the top of the file?