我知道存在舍入错误,但任何人都可以解释为什么我使用这些不同的方法得到如此不同的结果:
decimal amount = 9.990M;
var cost = Convert.ToInt32(amount*1000);
var cost1 = (int) amount*1000;
Run Code Online (Sandbox Code Playgroud)
我明白了:
cost = 9990
cost1 = 9000
Run Code Online (Sandbox Code Playgroud) c# ×1