I want to create "Blank if zero" format atring similar to VFP @Z function code or report designer checkbox.
This format string for decimal data type
should show blank if number is zero and otherwize in default format.
I tried format string f;f;# but this shows f for nonzero numbers.
Which format string to use ?
Andrus.
using System.Windows.Forms;
class AppMainEntry
{
static void Main()
{
// Expected: 0.40 actual: f
MessageBox.Show((0.40m).ToString("f;;#"));
// expected: 123.40 actual: f
MessageBox.Show((123.40m).ToString("f;;#"));
// expected: 123.4 actual: f
MessageBox.Show((123.4m).ToString("f;;#"));
// OK: expected: empty actual: empty
MessageBox.Show((0m).ToString("f;;#"));
}
}
Andrus