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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -