Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XDocument.Descendants("somethinghere").Count() method does not exist

Tags:

c#

xml

linq

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.

like image 361
Vance Smith Avatar asked Dec 17 '22 13:12

Vance Smith


1 Answers

Do you have using System.Linq; at the top of the file?

like image 161
svick Avatar answered Feb 24 '23 16:02

svick