ArrayList转换类型为DataTable类型
2016-04-06 14:08
316 查看
/// <summary> /// ArrayList转换类型为DataTable /// </summary> /// <param name="list"></param> /// <returns></returns> public static DataTable ToDataTableTow(IList list) { DataTable result = new DataTable(); if (list.Count > 0) { PropertyInfo[] propertys = list[0].GetType().GetProperties(); foreach (PropertyInfo pi in propertys) { result.Columns.Add(pi.Name, pi.PropertyType); } for (int i = 0; i < list.Count; i++) { ArrayList tempList = new ArrayList(); foreach (PropertyInfo pi in propertys) { object obj = pi.GetValue(list[i], null); tempList.Add(obj); } object[] array = tempList.ToArray(); result.LoadDataRow(array, true); } } return result; }
相关文章推荐
- Rsyslog配置
- Leetcode 19. Remove Nth Node From End of List(python)
- 恢复工具
- ColorProgress
- cocos2D-X源码分析之从cocos2D-X学习OpenGL(3)----BATCH_COMMAND
- ffplay不能直播red5上的直播流问题解决
- Linux - 常用命令
- 使用noatime提升文件系统性能
- [iOS]在运行时为类添加方法
- 关于play framework
- iOS开发 cocopods详细使用
- 获取安卓内存状态
- IIS6.0中ISAPI伪静态设置图文教程
- Asp.net下载文件几种方式
- ubuntu 14.04 将窗体button移到右边
- Mac下更改python版本为3.5
- 让Visual Studio 也支持JS代码折叠 [ Visual Studio | #region | #endregion ]
- Android通过Movie展示Gif格式图片
- 极速手游加速SDK快速指入指南+极速手游加速器SDK参考文档
- git 合并最后两次的commit