温伟的程序生活,一步一个脚印
自己会努力,做真正独一无二的温伟!无论前方有多难,我都不会放弃... 每一篇日志,都是我的积累,全是我的原创!

这段代码一直记着,他是我研究DataSet,DataTable,XML的开始

            DataSet dataSet = new DataSet("dataSet");
            DataTable table = dataSet.Tables.Add("Items");
            table.Columns.Add("id", typeof(int));
            table.Columns.Add("Item", typeof(string));

            DataRow row;
            for (int i = 0; i < 3; i++)
            {
                row = table.NewRow();
                row["id"] = i;
                row["Item"] = "Item" + i;
                table.Rows.Add(row);
            }

            Console.WriteLine(dataSet.GetXml());

结果:<dataSet>
              
<Items>
                    <id>0<id>
                    <Item>Item0</Item>
               <Items>
               <Items>
                    <id>1<id>
                    <Item>Item1</Item>
               <Items>
               <Items>
                    <id>2<id>
                    <Item>Item2</Item>
               <Items>

         
<dataSet>

posted on 2008-12-02 16:31  winvay  阅读(323)  评论(0编辑  收藏  举报