获得Boolean NULL 相关的值
2014-11-14 10:07:21 访问(1783) 赞(0) 踩(0)
/// <summary>
/// 获得Boolean NULL 相关的值
/// </summary>
/// <param name="oValue"></param>
/// <returns></returns>
private static bool? GetBooleanNullByObj(object oValue)
{
if (oValue == null || oValue == DBNull.Value)
return null;
if (oValue is Boolean)
return (bool?)oValue;
string str = oValue.ToString();
if (str.Length == 0)
return null;
str = str.Trim();
if (str.Length == 0)
return null;
if (str == "1")
return true;
if (str == "0")
return false;
throw new Exception("str == " + str + " 不是有效的Boolean值。");
}
标签:
获得Boolean NULL 相关的值 


上一条:
下一条:
相关评论
发表评论