有人可以解释为什么result1
isfalse
和result2
istrue
吗?代码如下:
namespace TestCsharp
{
class Program
{
static void Main(string[] args)
{
Order objOrder = new Order(0.0M);
bool result1 = objOrder.PriceNullable.Equals(0);//returns false
bool result2 = objOrder.PriceNullable.Value.Equals(0);// returns true
}
}
public class Order
{
public decimal? PriceNullable { get; set; }
public Order(decimal? priceNullable)
{
PriceNullable = priceNullable;
}
}
}