c# XElement linq, return bool -
i need return bool type field contains 1 or 0
<auto>1</auto> code
public bool getbooksauto() { return (bool)xd.elements("root").elements("books").elements("auto") .select(x => x) .any(); } can written in 1 return line or should test strings 1 , 0. thank you!
if want check whether of auto elements has value 1:
xd.elements("root").elements("books").elements("auto") .select(a => (int)a == 1) // here true if value 1 , false if 0 .any() you can put condition directly any operator:
xd.elements("root").elements("books").elements("auto").any(a => (int)a == 1)
Comments
Post a Comment