using System;
using System.Collections.Generic;
using System.Linq;namespace ConsoleApp1
{class Program{static void Main(string[] args){//var a = 5;var a = 24;// 整数前面补N个0以保存对齐Console.WriteLine("{0:D4}", a);Console.WriteLine(a.ToString("D4"));Console.WriteLine(a.ToString().PadLeft(4, '0'));//Console.WriteLine(a.ToString().PadRight(4, '0'));Console.WriteLine(a.ToString("0000"));}}
}
运行结果:
0024
0024
0024
0024
请按任意键继续. . .