Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to avoid the error and get 0 for empty value
Message
 
 
À
Tous
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Titre:
Best way to avoid the error and get 0 for empty value
Divers
Thread ID:
01654373
Message ID:
01654373
Vues:
44
Hi everybody,

I now have a code like this in a few places:
parameter.Value = Convert.ToDecimal(parameterValue, CultureInfo.InvariantCulture);
In that method I also added CultureInfo.InvarianCulture to conversions to Int, Double, etc.

The problem is that now passing empty string throws an error. I can add checking for empty strings and using "0" instead but is there a more elegant solution so I would not need to fix in many places?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform