Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating Blank if zero decimal format string
Message
De
30/08/2008 12:55:06
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Common Language Runtime
Titre:
Creating Blank if zero decimal format string
Divers
Thread ID:
01343549
Message ID:
01343549
Vues:
118
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform