Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
function zeroPad(num, places){ var zero = places - num.toString().length + 1; return Array(+(zero > 0 && zero)).join("0") + num; }
上記コードの意味とC#での使い方を教えてください
コードは Javascript でありnum、長さまでゼロで数値を埋めます。placesたとえば、. C# では、メソッドを使用してこれを行うことができます。たとえば、上記と同じ結果が得られます。zeroPad(12, 4)0012PadLeft()12.ToString().PadLeft(4, '0')0012
num
places
zeroPad(12, 4)
0012
PadLeft()
12.ToString().PadLeft(4, '0')