现在的位置: 首页 > 综合 > 正文

linq 读取xml文档中的数据自动类型转换

2013年10月14日 ⁄ 综合 ⁄ 共 606字 ⁄ 字号 评论关闭
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace linqToXml
{
    class Program
    {
        static void Main(string[] args)
        {
            XElement myE = new XElement("Number", 12);
            Console.WriteLine(myE);
            Console.WriteLine("---------------------------");
            Console.WriteLine((int)myE);
            

            XElement mE2 = new XElement("pi", 32.23323232);
            Console.WriteLine("--------------------------");
            Console.WriteLine(mE2);
            Console.WriteLine((double)mE2);


            XElement mE3 = new XElement("havaChild", true);
            Console.WriteLine("---------------------------");
            Console.WriteLine(mE3);
            Console.WriteLine((bool)mE3);
            Console.ReadLine();
        }
    }
}




抱歉!评论已关闭.