int aa = 11; string aastr = aa.ToString("000"); //或 string aastr = aa.ToString().PadLeft(3,‘0‘); //结果:011 int num=2; //三位,不足左侧补零 string str = string.format("{0:d3}",num); //结果:002 string str1 = string.format("{0}{{1:d4}}","1001",12); //结果:10010012
转:https://www.cnblogs.com/jiangyunfeng/p/13355677.html