c# - How to know if IEnumerable<XElement> is empty -
how know if item null(empty)?
xmldoc = xdocument.load("file.xml"); ienumerable<xelement> item = el in xmldoc.descendants("item") (string)el.attribute("name") == "google" select el;
something instead of if(item==null )
you can use item.any()
check item exist
you can check count
prefer have any
ienumerable<t>
check out which method performs better: .any() vs .count() > 0?
Comments
Post a Comment