locked
Add Zero before number RRS feed

  • Question

  • Hi All,

          I have a requirement like

    if number is 3 then i need to show as 003

    if number is 4 then 0004 

    if number is 5 then 00005

    can you please let me know how to do it in C#

    Wednesday, February 11, 2015 7:29 AM

All replies

  • What is number 's data type ? Is it number (integer ) or string ?

    below code, you can try :

    int i = 3;
    string s = i.ToString().PadLeft(I-1, '0');


    Wednesday, February 11, 2015 10:17 AM