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

推荐订阅源

P
Proofpoint News Feed
博客园 - 聂微东
Application and Cybersecurity Blog
Application and Cybersecurity Blog
MyScale Blog
MyScale Blog
罗磊的独立博客
H
Help Net Security
L
LangChain Blog
T
Threat Research - Cisco Blogs
量子位
S
Securelist
Last Week in AI
Last Week in AI
L
Lohrmann on Cybersecurity
T
The Exploit Database - CXSecurity.com
P
Privacy International News Feed
The Hacker News
The Hacker News
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Blog of Author Tim Ferriss
T
Threatpost
Security Latest
Security Latest
P
Palo Alto Networks Blog
Microsoft Security Blog
Microsoft Security Blog
NISL@THU
NISL@THU
F
Full Disclosure
WordPress大学
WordPress大学
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Heimdal Security Blog
J
Java Code Geeks
Recorded Future
Recorded Future
Hugging Face - Blog
Hugging Face - Blog
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
阮一峰的网络日志
阮一峰的网络日志
U
Unit 42
B
Blog RSS Feed
月光博客
月光博客
C
Cisco Blogs
V
Visual Studio Blog
D
DataBreaches.Net
H
Hacker News: Front Page
博客园 - 叶小钗
N
News and Events Feed by Topic
爱范儿
爱范儿
A
Arctic Wolf

博客园 - 农村的芬芳

PHP使用第三篇:生成数据库 使用THINKPHP产生的:No database selected [问题 从今天开始记录PHP使用的点点滴滴 留给自个看的工具提示 转xml Oracle 跨库 查询 复制表数据 关于海量数据处理 近日用到啦progressbar控件,将其用法留一下 select into 和 insert into select 两种表复制语句 采用regsvr32注册组件后提示:没有注册 将对象数组转换成dataset windows 服务操作 转载:XML与DataSet的相互转换类 oracle 日期函数小计 如何创建自定义帐户来运行 ASP.NET 通过ASP.net程序创建域帐户故障 EnterpriseLibrary服务问题 下载文件关闭窗体之解决方法 超级郁闷之问题,请DUDU及各位大位指正错误
net2005中将list<>数组转换为Table
农村的芬芳 · 2007-11-16 · via 博客园 - 农村的芬芳

 public static DataTable GetDataTableFromIList<T>(List<T> aIList)
        {

            DataTable _returnTable = new DataTable();

            if (aIList.Count > 0)
            {

                //Creates the table structure looping in the in the first element of the list

                object _baseObj = aIList[0];

                Type objectType = _baseObj.GetType();

                PropertyInfo[] properties = objectType.GetProperties();

                DataColumn _col;

                foreach (PropertyInfo property in properties)
                {

                    _col = new DataColumn();

                    _col.ColumnName = (string)property.Name;

                    _col.DataType = property.PropertyType;

                    _returnTable.Columns.Add(_col);

                }

                //Adds the rows to the table

                DataRow _row;

                foreach (object objItem in aIList)
                {

                    _row = _returnTable.NewRow();

                    foreach (PropertyInfo property in properties)
                    {
                        _row[property.Name] = property.GetValue(objItem, null);
                    }
                    _returnTable.Rows.Add(_row);

                }

            }

            return _returnTable;

        }