Thursday, April 12, 2007 6:11 PM
bart
C# Quiz - Fun with System.Xml
A simple quiz today; it's rather a System.Xml debugging job. With this I've said too much already. Here it is:
Copy Code 1 using System;
2 using System.Xml;
3
4 class Program
5 {
6 static void Main()
7 {
8 new Bar<int>().CreateBar<double>("Bart").CreateBar<long>("DeSmet");
9 }
10 }
11
12 class Bar<T>
13 {
14 static XmlDocument doc = new XmlDocument();
15
16 private XmlElement root;
17
18 public Bar()
19 {
20 root = doc.CreateElement("Root");
21 }
22
23 private Bar(XmlElement root) { this.root = root; }
24
25 public Bar<S> CreateBar<S>(string foo)
26 {
27 XmlElement f = doc.CreateElement(foo);
28 root.AppendChild(f);
29 return new Bar<S>(root);
30 }
31 }