numeric with leading zeros

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lazerbrain
    New Member
    • Nov 2011
    • 1

    numeric with leading zeros

    How can I represent eg. 23633.78 with leading zeros in format:
    000000002363378

    In other words the field is 15 characters length and when I put number I want to place leading zeroes on the left. The number must not be rounded!

    Thanks in advance for your help!
  • mcfly1204
    New Member
    • Jul 2007
    • 233

    #2
    If you know that you will always want to display two decimal places, you can just convert the number to a string and format the string.

    Code:
    decimal number = 23633.78M;
    
    string formattedNumber = string.Format("{0:000000000000.00}", number);

    Comment

    Working...