C# 求百分比并保留2位小数

int a = 41, b = 48;
decimal c = (decimal)a / b;

decimal result_d = Math.Round(c * 100, 2);
string result = (Math.Round(c * 100, 2)).ToString() + "%";

Console.WriteLine(100 - result_d);
Console.WriteLine(result);
Console.ReadKey();

 

posted @ 2018-08-01 13:28  zhyue93  阅读(829)  评论(0编辑  收藏  举报