Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating Blank if zero decimal format string
Message
From
30/08/2008 12:55:06
 
 
To
All
General information
Forum:
ASP.NET
Category:
Common Language Runtime
Title:
Creating Blank if zero decimal format string
Miscellaneous
Thread ID:
01343549
Message ID:
01343549
Views:
117
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
Next
Reply
Map
View

Click here to load this message in the networking platform