How to check if Datarow value is null

后端 未结 2 1078
南方客
南方客 2020-12-09 15:31

Tell me please is this is correct way to check NULL in DataRow if need to return a string

 Convert.ToString(row[\"Int64_id\"] ?? \"\")
         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-09 16:08

    Check if the data column is not null with DataRow.IsNull(string columnName)

    if (!row.IsNull("Int64_id"))
    {
      // here you can use it safety
       long someValue = (long)row["Int64_id"];
    }
    

提交回复
热议问题