float num = 1.123F; string result = num.ToString("0.##"); //1.12 Console.WriteLine(result); result = num.ToString(".##"); //1.12 Console.WriteLine(result); num = 0.123F; result = num.ToString("0.##"); //0.12 Console.WriteLine(result); result = num.ToString(".##"); //.12 //注意,此处没0了 Console.WriteLine(result); num = 0F; result = num.ToString("0.##"); //0 Console.WriteLine(result); result = num.ToString(".##"); //空白 //注意,此处没0了 Console.WriteLine(result); //价格格式 num = 10.25F; result = num.ToString("C"); Console.WriteLine(result); //¥10.25 //科学计数法 num = 1110000; result = num.ToString("E"); Console.WriteLine(result); //1.110000E+006 //四舍五入保留一位小数 num = 123.153F; result = num.ToString("F1"); //四舍五入保留一位小数 Console.WriteLine(result); //123.2 //四舍五入保留2位小数 num = 123; result = num.ToString("F2"); Console.WriteLine(result); //123.00 Console.ReadKey();