天天看点

C#实现数字字符串左补齐0的两种方法

2种方法实现数字字符串的左补齐0

                int n = 3;

                string s = n.ToString().PadLeft(4, '0'); //0003

                s = string.Format("{0:d4}", n);          //0003

本文转自 h2appy  51CTO博客,原文链接:http://blog.51cto.com/h2appy/1171789,如需转载请自行联系原作者