Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.24 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to display the number “12” in the format of “0000012”
  2. var formatted = String.Format("{0:0000000}", 12);
  3.        
  4. Console.WriteLine("{0:0000000}", 12);
  5.        
  6. var formatted = "12".PadLeft(7, '0');
  7.        
  8. var a = 12;
  9. var b = a.ToString("D7");