c# - string.format() not showing values -


can tell me why string.format() doesn't show 1st value?

long countloop = 0; long counttotal = 3721;  string.format("processed {0:#,###,###} lines of {1:#,###,###} ({2:p0})", countloop, counttotal, ((double)countloop / counttotal)); 

the result got are

processed  lines of 3,721 (0 %)  

but if replaced counttotal number 1

string.format("processed {0:#,###,###} lines of {1:#,###,###} ({2:p0})", 1, counttotal, ((double)countloop / counttotal)); 

i

processed 1 lines of 3,721 (0 %).

is there string.format don't know about?

see documentation on the "#" custom format specifier:

note specifier never displays 0 not significant digit, if 0 digit in string.

if you'd display "0" in case, take @ the "0" custom format specifier:

if value being formatted has digit in position 0 appears in format string, digit copied result string; otherwise, 0 appears in result string.

this should work you:

string.format(     "processed {0:#,###,##0} lines of {1:#,###,###} ({2:p0})",      countloop, counttotal, ((double)countloop / counttotal)); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -