首页 技术 正文
技术 2022年11月20日
0 收藏 905 点赞 2,801 浏览 1267 个字

static void Main(string[] args)        {    // Create the data source by using a collection initializer.            var students = new[]        {            new {First=”Svetlana”, Last=”Omelchenko”, ID=111, Scores = new List<int>{97, 92, 81, 60}},            new {First=”Claire”, Last=”O’Donnell”, ID=112, Scores = new List<int>{75, 84, 91, 39}},            new {First=”Sven”, Last=”Mortensen”, ID=113, Scores = new List<int>{88, 94, 65, 91}},        };             // Create the query.            var studentsToXML = new XElement(“Root”,                from student in students                let x = String.Format(“{0},{1},{2},{3}”, student.Scores[0],                        student.Scores[1], student.Scores[2], student.Scores[3])                select new XElement(“student”,                           new XElement(“First”, student.First),                           new XElement(“Last”, student.Last),                        new XElement(“Scores”, x)                        ) // end “student”                    ); // end “Root”             // Execute the query.            Console.WriteLine(studentsToXML);             // Keep the console open in debug mode.            Console.WriteLine(“Press any key to exit.”);            Console.ReadKey();         } 运行经结果: C# LINQ to XML示例

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,105
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,582
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,429
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,836
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,919