你有没有尝试过使用value = Decimal.Round(value, 2)
?
例如:
using System;
class Test
{
static void Main()
{
decimal d = 1234.5678m;
Console.WriteLine("Before: {0}", d); // Prints 1234.5678
d = decimal.Round(d, 2);
Console.WriteLine("After: {0}", d); // Prints 1234.57
}
}
请注意,这是四舍五入而不仅仅是修剪(所以这里四舍五入)......您到底需要什么?有可能Decimal
struct 支持您需要做的任何事情。咨询MSDN以获得更多选择。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)