1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ConsoleApp1 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 int n1 = 10; 14 int n2 = 3; 15 double d = n1 * 1.0 / n2;//n1乘以1.0后就已经转为了double型 16 17 18 Console.WriteLine("{0:0.00}", d);//通过"{0:0.00}",使得结果只保留两位小数 19 Console.ReadKey(); 20 21 22 23 24 } 25 } 26 }