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();
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();