1 int i = 10; 2 Console.WriteLine(i.ToString("D3")); 3 Console.WriteLine(i.ToString("000")); 4 Console.WriteLine(i.ToString().PadLeft(3,'0'));
MSDN字符串格式相關參考:https://msdn.microsoft.com/zh-cn/library/dwhawy9k.aspxspa