日期:2014-05-18  浏览次数:20922 次

如何保留两位小数?
总次数 = 3776

C# code
double total = DataGrid.cell(1,1).IntegerValue;


具体次数

C# code
DataGrid.Cell(1, 2).Text = (((int)total * 0.01)).ToString();


使用了

C# code
math.round(xxx,2)


但是显示的是:整数 37

如何得到37.76呢?

------解决方案--------------------
DataGrid.Cell(1, 2).Text = (total * 0.01).ToString(F2);//不要使用int,
------解决方案--------------------
DataGrid.Cell(1, 2).Text = (((int)total * 0.01)).ToString();
真搞不懂你为什么给total转换成int类型,直接(total * 0.01).ToString();
真的多此一举

------解决方案--------------------
ToString("0.00");
------解决方案--------------------
应该不会啊,可以保留小数部分啊
C# code
int i = 3776;Console.Write(Math.Round(i * 0.01,2));  37.76