码迷,mamicode.com
首页 > Windows程序 > 详细

(C# 基础) Datatable

时间:2015-09-17 13:39:10      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

增加一行:

 

DataTable measurements = new DataTable();
                                measurements.Columns.Add("StationTestName", typeof(string));
                                measurements.Columns.Add("SerialNumber", typeof(string));
                                measurements.Columns.Add("MeasurementName", typeof(string));
                                measurements.Columns.Add("Unit", typeof(string));
                                measurements.Columns.Add("Value", typeof(string));
                                measurements.Columns.Add("LowerLimit", typeof(string));
                                measurements.Columns.Add("UpperLimit", typeof(string));
                                measurements.Rows.Add(
                                    stationTestName,
                                    serialNumber,
                                    measurementSplits[0],
                                    measurementSplits[1],
                                    measurementSplits[2],
                                    measurementSplits[3],
                                    measurementSplits[4]);

 

 

 

 

取指定的其中一列的值:

How to Get a Specific Column Value from a DataTable? 

datatable1.AsEnumerable().Select(r => r.Field<string>("Name")).ToArray();
datatable1.Rows.Cast<DataRow>().Select(r => r.ItemsArray[0].ToString()) 

 

(C# 基础) Datatable

标签:

原文地址:http://www.cnblogs.com/fdyang/p/4815913.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!