Response.Write((1.5).ToString("0")); // 2 Response.Write((2.5).ToString("0")); // 3 Response.Write((-1.5).ToString("0")); // -2 Response.Write((-2.5).ToString("0")); // -3
我们可以看出 ToString 的四舍五入,是按普通的见 5 就入,而不是 Math.Round 默认的向最近的偶数靠近。
相关阅读
微软中文对 C# Math.Round 中 MidpointRounding.AwayFromZero 的描述是错误的
创建于2005年 渝ICP备05010272号-1
电邮:cftea@126.com