Get a DataTable Columns DataType

前端 未结 5 1113
萌比男神i
萌比男神i 2021-01-31 14:49
DataTable dt = new DataTable();  
dt.Columns.Add(new DataColumn(gridColumn1, typeof(bool)));

I was expecting the result of the below line to include in

5条回答
  •  悲哀的现实
    2021-01-31 15:23

    You could always use typeof in the if statement. It is better than working with string values like the answer of Natarajan.

    if (dt.Columns[0].DataType == typeof(DateTime))
    {
    }
    

提交回复
热议问题