コード例 #1
0
        static void Main(string[] args)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Selection", typeof(string));
            dt.Rows.Add(new object[] { "Color", "1,2,3" });
            dt.Rows.Add(new object[] { "Shape", "a,b" });
            dt.Rows.Add(new object[] { "Cut", "x" });
            dt.Rows.Add(new object[] { "Range", "y" });
            dt.Rows.Add(new object[] { "Purity", "8,9" });
            Recursion     recursion = new Recursion(dt);
            List <string> results   = recursion.GetData(0);
        }
コード例 #2
0
 static void Main(string[] args)
 {
     string xml =
         "<table border=\"1\">" +
         "<tr>" +
         "<td><b>Name</b></td>" +
         "<td><b>Selection</b></td>" +
         "</tr>" +
         "<tr>" +
         "<td>Color</td>" +
         "<td>1,2,3</td>" +
         "</tr>" +
         "<tr>" +
         "<td>Shape</td>" +
         "<td>a,b</td>" +
         "</tr>" +
         "<tr>" +
         "<td>Cut</td>" +
         "<td>x</td>" +
         "</tr>" +
         "<tr>" +
         "<td>Range</td>" +
         "<td>y</td>" +
         "</tr>" +
         "<tr>" +
         "<td>Purity</td>" +
         "<td>8,9</td>" +
         "</tr>" +
         "</table>";
     XElement    table = XElement.Parse(xml);
     List <Data> data  = table.Descendants("tr").Select(x => new Data()
     {
         name   = x.Elements().Take(1).FirstOrDefault().Value,
         values = x.Elements().Skip(1).FirstOrDefault().Value.Split(new char[] { ',' }).ToList()
     }).Skip(1).ToList();
     Recursion     recursion = new Recursion(data);
     List <string> results   = recursion.GetData(0);
 }