How to

format number with leading zeros

Published: 14. October 2011 | Updated: 14. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework
Tags: C# Formatting Text
Was this snippet helpful for you? YESYES / NONO
int number = 546;
string formatted = number.ToString("000000");

Console.WriteLine(formatted);
Console Output:
000546
Send us feedback about this snippet »



Related Snippets: