Number of columns in dataset

前端 未结 2 1926
渐次进展
渐次进展 2021-01-23 07:25

Is it possible to find the number of columns a data set has?

I know we can find the length of rows with:

ds.Tables[0].Rows.length

Is th

2条回答
  •  孤街浪徒
    2021-01-23 07:59

    Use the DataTable.Columns.Count property. So ds.Tables[0].Columns.Count.

    If you have a DataRow you can also use this property via...

    int columnCount = row.Table.Columns.Count;
    

    or another option is the DataRow.ItemArray which contains all fields:

    int columnCount = row.ItemArray.Length; 
    

提交回复
热议问题