string formatting - Is there a C# format specifier that will omit the leading zero unless the value is zero? -
in other words, want 0.123 show ".123", 0 should show "0". best i've got is
string.format("{0:.###}", n)
which gives ".123" 0.123, "" (the empty string) 0.
if use ;
separator, can specify formats positive, negative, , 0 values. string.format("{0:.###;-.###;0}", n)
display '0' when n==0
, leave off leading 0 positive , negative values. check msdn reference here.
Comments
Post a Comment