数字格式:如何转换1" 01 QUOT,2至" 02"等?

问题描述:

我有号码,如1,2,3,我想使他们成为字符串,01,02和03。我怎样才能做到这一点?

I have numbers like 1, 2, and 3, and I would like to make them into strings, "01", "02" and "03". How can I do this?

这里是MSDN上的格式条款数字的。要垫2个数字,你可以使用:

Here is the MSDN article on formatting numbers. To pad to 2 digits, you can use:

n.ToString("D2")