如何将float转换为int - 类型转换为字符串格式?

时间:2012-06-12 09:35:27

标签: c# asp.net floating-point int type-conversion

我想键入以下内容的转换。

我的C#代码是。

float percentage = (present/total) * 100;
lblPercentage.Text += String.Format("{0:0.00}", (float)present / (float)total);

它提供的输出如下:0.71但我希望输出类似于:71

1 个答案:

答案 0 :(得分:3)

我认为您应该使用{0:p}作为格式,然后使用%符号正确显示