I am translating some code from VB to C# and came across this:
Format(seg.R, " 00.00000;-00.00000") // <-- There is a leading space in the first format string
...which prints...
00.00000 //or...
-00.00000
...depending on whether the decimal is positive or negative. Is there an easy way to do this with the C# string.Format
or myObj.ToString("[format here]")
functions?
EDIT: Notice the extra space in the format string. This makes the strings the same length by adding a leading space when there is no negative sign.