XElement to DateTime Cast
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass{
public static void Main(){
XElement root = new XElement("Root", new DateTime(2010, 10, 6, 12, 30, 0));
Console.WriteLine(root);
DateTime dt = (DateTime)root;
Console.WriteLine("dt={0}", dt);
XElement dtElement = new XElement("OrderDate", "October 6, 2006");
Console.WriteLine(dtElement);
DateTime orderDate = (DateTime)dtElement;
Console.WriteLine("orderDate={0:d}", orderDate);
}
}
Related examples in the same category