C# 格式化输出
2021-05-28 14:07
标签:space ons mes text names read collect lin pac using System; namespace ConsoleApplication1 } 输出: C# 格式化输出 标签:space ons mes text names read collect lin pac 原文地址:https://www.cnblogs.com/zhaiyh/p/11129529.html
using System.Collections.Generic;
using System.Text;
{
class Program
{
static void Main(string[] args)
{
double n = 10.0 / 3;
Console.WriteLine(n);
Console.WriteLine("{0:0.00}", n); //保留两位小数
string str = n.ToString("0.000"); //转成含三位小数的字符串
Console.WriteLine(str);
Console.ReadKey();
}
}