I currently convert an integer to a string for display to the screen, but wish to maintain 4 digits - i.e 10 = "0010". What is the best way of going from an integer of 10 to a string of "0010"?

This is in C# and .NET 4.

Cheers!
['https://Stackoverflow.com/questions/13542805', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1299105/']
```
var str = 10.ToString("0000");

```
You can try :-

```
 string str = num.ToString("D8"); //padding with 8 zero's

```

Check this [link](http://msdn.microsoft.com/en-us/library/dd260048.aspx)