如何让结果保留小数点后四位
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyTest
{
class Test
{
static void Main(string[] args)
{
float price1 = 27.3f;
float price2 = 57.0f;
int n1 = 2;
int n2 = 3;
float discount = 0.2f;
double total = price1 * n1 + price2 * n2;
if (total > 200 || (price1 > 100 && price2 > 100))
{
total = total * (1 - discount);
Console.WriteLine("折后总消费金额为:{0}", total);
}
else
Console.WriteLine("总消费金额为:{0}", total);
Console.ReadKey();
}
}
}