Adding zeros to front of an int.

Is there a way for me to add zeros to the front of an int, but keep it limited to 3 digits with code? For example if the int: 8 was supplied it would give me 008, but then if say the int: 17 was supplied it would give me 017 and then if 479 it would give 479. Thanks!

1 Answer

1

Use the standard string formatting:

var foo = 42;
print (foo.ToString("000"));