March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
58
Task/Create-an-HTML-table/C-sharp/create-an-html-table-2.cs
Normal file
58
Task/Create-an-HTML-table/C-sharp/create-an-html-table-2.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace N
|
||||
{
|
||||
public class T
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
var headerNames = new [] { "", "X", "Y", "Z" };
|
||||
|
||||
var headerColumns = headerNames.Select(name =>
|
||||
new XElement
|
||||
(
|
||||
"th",
|
||||
name,
|
||||
new XAttribute("text-align", "center")
|
||||
)
|
||||
);
|
||||
|
||||
var rows = Enumerable.Range(0, 4)
|
||||
.Select
|
||||
(
|
||||
rowIndex =>
|
||||
new XElement
|
||||
(
|
||||
"tr",
|
||||
new XElement("td", rowIndex),
|
||||
Enumerable.Range(0, 4)
|
||||
.Select
|
||||
(
|
||||
colIndex =>
|
||||
new XElement
|
||||
(
|
||||
"td",
|
||||
colIndex,
|
||||
new XAttribute("text-align", "center")
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
var xml = new XElement
|
||||
(
|
||||
"table",
|
||||
new XElement
|
||||
(
|
||||
"thead",
|
||||
new XElement("tr", headerColumns),
|
||||
new XElement("tbody", rows)
|
||||
)
|
||||
);
|
||||
|
||||
Console.WriteLine(xml.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue