关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回

(C#基础)Datatable

发布时间:2022-07-27 13:55:24
增加一行:(C#基础)Datatable
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()) 

/template/Home/DawnNew/PC/Static

立即注册风纳云账号,免费体验多款产品

立即注册