Mega Code Archive

 
Categories / C# / XML LINQ
 

Cast the value of this XAttribute to a Boolean

using System; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         XElement root = new XElement("Root",              new XAttribute("BoolValue", true)         );         bool bv = (bool)root.Attribute("BoolValue");         Console.WriteLine("(bool)BoolValue={0}", bv);    } }