0
  function zeroPad(num, places){
        var zero = places - num.toString().length + 1;
        return Array(+(zero > 0 && zero)).join("0") + num;
    }

Please tell me the means of code above, and how to use it on C#

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • Thats JavaScript to add *n* leading zeros... For C# cast to string & use `.PadLeft` http://stackoverflow.com/questions/3122677/add-zero-padding-to-a-string – Alex K. Jun 26 '15 at 11:08
  • Don't add "[tag]Solved[/tag]" to your title, accept the answer. – CodeCaster Jun 26 '15 at 11:21
  • Here's how you should [accept an answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) – Thomas Ayoub Jun 26 '15 at 11:22

1 Answers1

1

The code is Javascript and pads the number num with zeros to the length places, for example zeroPad(12, 4) gives you 0012. In C# you can do this with the PadLeft() method, for example 12.ToString().PadLeft(4, '0') which gives you the same as above 0012.

Raidri
  • 17,258
  • 9
  • 62
  • 65