Сообщение Как развернуть список от 01.05.2016 5:06
Изменено 01.05.2016 5:12 Arsen.Shnurkov
Из задач на собеседование, скастуйте сюда mgu, а то я не умею
http://rsdn.ru/forum/job/6423376.1
моё время решения — 40 минут
http://rsdn.ru/forum/job/6423376.1
Автор: mgu
Дата: 21.04.16
Дата: 21.04.16
/*
http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument
http://stackoverflow.com/questions/747554/populate-xdocument-from-string
http://stackoverflow.com/questions/956749/how-can-i-transform-xml-into-a-liststring-or-string
http://stackoverflow.com/questions/19102021/how-to-reverse-a-generic-list-without-changing-the-same-list
http://stackoverflow.com/questions/17043663/how-to-serialize-a-listt-into-xml
*/
using System;
using System.IO;
using System.Xml.Linq; // add System.Xml.Linq.dll to references
using System.Linq;
class MainClass
{
public static void Main (string[] args)
{
//
var doc = XDocument.Parse(@"<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>");
var list = doc.Root.Elements("li")
.Select(element => element.Value)
.ToList();
var reversed_list = list.AsEnumerable().Reverse();
XElement xmlElements = new XElement("ul", reversed_list.Select(i => new XElement("li", i)));
System.Console.Write(xmlElements);
}
}
моё время решения — 40 минут
Из задач на собеседование,
http://rsdn.ru/forum/job/6423376.1
http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument
http://stackoverflow.com/questions/747554/populate-xdocument-from-string
http://stackoverflow.com/questions/956749/how-can-i-transform-xml-into-a-liststring-or-string
http://stackoverflow.com/questions/19102021/how-to-reverse-a-generic-list-without-changing-the-same-list
http://stackoverflow.com/questions/17043663/how-to-serialize-a-listt-into-xml
моё время решения — 40 минут
http://rsdn.ru/forum/job/6423376.1
Автор: mgu
Дата: 21.04.16
Дата: 21.04.16
using System;
using System.IO;
using System.Xml.Linq; // add System.Xml.Linq.dll to references
using System.Linq;
class MainClass
{
public static void Main (string[] args)
{
//
var doc = XDocument.Parse(@"<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>");
var list = doc.Root.Elements("li")
.Select(element => element.Value)
.ToList();
var reversed_list = list.AsEnumerable().Reverse();
XElement xmlElements = new XElement("ul", reversed_list.Select(i => new XElement("li", i)));
System.Console.Write(xmlElements);
}
}
http://stackoverflow.com/questions/1542073/xdocument-or-xmldocument
http://stackoverflow.com/questions/747554/populate-xdocument-from-string
http://stackoverflow.com/questions/956749/how-can-i-transform-xml-into-a-liststring-or-string
http://stackoverflow.com/questions/19102021/how-to-reverse-a-generic-list-without-changing-the-same-list
http://stackoverflow.com/questions/17043663/how-to-serialize-a-listt-into-xml
моё время решения — 40 минут