How to display the number “12” in the format of “0000012” Using C#
var str = string.Format("{0:d7}", 12);
var formatted = String.Format("{0:0000000}", 12);
or
Console.WriteLine("{0:0000000}", 12);
I will add that if "12" is a string
(it's in double quotes)
var formatted = "12".PadLeft(7, '0');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With