惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - goodvify

电费查询网_电费网上查询 气候数据订制 天气后报 第二架遥控飞机又飞丢了,囧! 外贸业务可以分为多个工作阶段来管理 也许许多企业管理软件的设计出发点就错了 在Linux下的绘流程图工具yEd 在Flex中用xml做数据源的界面操作的测试 “学而不思则罔,思而不学则殆”在实施工作中的思考 Ubuntu Server安装 准备测试使用Ubuntu的Server版 不使用“DataSourceControl DataSource”的情况下如何分页和排序 [转]PetShop 4架构分析 VS2008 快捷键大全 ASP.NET2.0网页的生命周期 MySql远程连接的问题 vc7中的ClassWizard [javascript]判断email地址的有效性 Windows Socket API函数解说
[转]利用.NET中的反射机制实现IList到DataTable的转换
goodvify · 2009-01-02 · via 博客园 - goodvify

 public static DataSet ListToDataSet(IList ResList)
 {
      DataSet RDS=new DataSet();
      DataTable TempDT = new DataTable();
      //此处遍历IList的结构并建立同样的DataTable
      System.Reflection.PropertyInfo[] p = ResList[0].GetType().GetProperties();
      foreach (System.Reflection.PropertyInfo pi in p)
      {
           TempDT.Columns.Add(pi.Name,System.Type.GetType(pi.PropertyType.ToString()));
      }
      for (int i = 0; i < ResList.Count; i++){
           IList TempList = new ArrayList();
           //将IList中的一条记录写入ArrayList
           foreach (System.Reflection.PropertyInfo pi in p)
           {
                object o = pi.GetValue(ResList[i], null);
                TempList.Add(o);
           }
           object[] itm=new object[p.Length];
           //遍历ArrayList向object[]里放数据
           for (int j = 0; j < TempList.Count; j++)
           {
                itm.SetValue(TempList[j], j);
           }
           //将object[]的内容放入DataTable
           TempDT.LoadDataRow(itm, true);
      }
      //将DateTable放入DataSet
      RDS.Tables.Add(TempDT);
      //返回DataSet
      return RDS;
 }