我有一个小数字段
[Display(Name = "DeductedTax")]
[Required(ErrorMessage = "*")]
public decimal DeductedTax { get; set; }
现在在 If 语句中,我想将其与零进行比较,实际上我想检查Deducted Tax
是否为零或 null
if (payRoll.DeductedTax <= 0)
{
if (payRoll.PayRollEmployee.EmployeeSalary.PayGrade == "A+")
{
payRoll.DeductedTax = payRoll.EmployeeSalary * 15 / 100;
payRoll.EmployeeSalary -= payRoll.DeductedTax;
}
else if (payRoll.PayRollEmployee.EmployeeSalary.PayGrade == "A")
{
payRoll.DeductedTax = payRoll.EmployeeSalary * 10 / 100;
payRoll.EmployeeSalary -= payRoll.DeductedTax;
}
else if (payRoll.PayRollEmployee.EmployeeSalary.PayGrade == "B")
{
payRoll.DeductedTax = payRoll.EmployeeSalary * 5 / 100;
payRoll.EmployeeSalary -= payRoll.DeductedTax;
}
}
为什么我不能将它与 null 之类的 nullif (payRoll.DeductedTax <= 0)
和零进行比较if (payRoll.DeductedTax <= 0)
?我应该怎么做才能完成我想要的操作?