标签:数据格式
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 数字格式化
{
class Program
{
static void Main(string[] args)
{
int i = 220;
Console.WriteLine("i = {0}",i);
int j = 25;
Console.WriteLine("j = {0}",j);
Console.WriteLine();
/*{参数,占位符(多少个空格)}*/
Console.WriteLine("{0,6}\n+{1,5}\n-------\n{2,6}",i,j,i+j);
/*
i = 220
j = 25
220
+ 25
-------
245
*/
decimal m = 19.23m;
decimal n = 73.7m;
Console.WriteLine("我现在有{0,5:C2}",m);
Console.WriteLine("然后有{0,7:C2}",n);
Console.WriteLine("{0,8:C2}\n+\n{1,7:C2}\n----------\n{2,8:C2}\n",m,n,m+n);
Console.ReadLine();
}
}
}
/*
i = 220
j = 25
220
+ 25
-------
245
我现在有¥19.23
然后有 ¥73.70
¥19.23
+
¥73.70
----------
¥92.93
*/
本文出自 “phize” 博客,请务必保留此出处http://12756301.blog.51cto.com/12746301/1970942
标签:数据格式
原文地址:http://12756301.blog.51cto.com/12746301/1970942