DBNull 与 求和方法

public int CountMoney()
{
if (!DBNull.Value.Equals(Eval("LawyerMoney")) && !DBNull.Value.Equals(Eval("OtherMoney")))
{
int money1 = Convert.ToInt32(Eval("LawyerMoney"));
int money2 = Convert.ToInt32(Eval("OtherMoney"));
return money1 + money2;
}
if (!DBNull.Value.Equals(Eval("LawyerMoney")) && DBNull.Value.Equals(Eval("OtherMoney")))
{
int money1 = Convert.ToInt32(Eval("LawyerMoney"));
return money1;
}
if (DBNull.Value.Equals(Eval("LawyerMoney")) && !DBNull.Value.Equals(Eval("OtherMoney")))
{
int money2 = Convert.ToInt32(Eval("OtherMoney"));
return money2;
}
else
{
return 0;
}
}

你可能感兴趣的:(null)