如何检查数据行值为null [英] How to check if Datarow value is null
本文介绍了如何检查数据行值为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请告诉我是这是检查NULL在DataRow中,如果需要返回一个字符串
<$ P正确方法$ p>
Convert.ToString(行[Int64_id] ??)
还是应该像检查与DBNull.Value。
需要这么多比
小
如果(行[Int64_id]!= DBNull.Value){...}否则,如果{}
解决方案
检查数据列不为null与的DataRow.IsNull(string COLUMNNAME)
如果( !row.IsNull(Int64_id))
{
//这里你可以使用它安全
长someValue中=(长)行[Int64_id];
}
Tell me please is this is correct way to check NULL in DataRow if need to return a string
Convert.ToString(row["Int64_id"] ?? "")
Or should be like check with DBNull.Value.
Need to so much more smaller than
if(row["Int64_id"] != DBNull.Value){...}else if{}
解决方案
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"];
}
这篇关于如何检查数据行值为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文