c# - Format string/number "NNNNN" -
i have write progression of number, having (each) 5 digit. code is:
int count = 1; string labelcount = ""; foreach (var directory in folderlist) { if (count < 10) { labelcount = "0000" + count.tostring(); } else if (count < 100) { labelcount = "000" + count.tostring(); } else if (count < 1000) { labelcount = "00" + count.tostring(); } else if (count < 10000) { labelcount = "0" + count.tostring(); } count++; }
but doesnt looks in opinion. there way format number (adding 0xn left) or that's way?
just give format tostring
method
var str = count.tostring("00000");
Comments
Post a Comment