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
De
15/09/2017 18:10:31
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01654373
Message ID:
01654374
Vues:
46
>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.

Use TryParse instead.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform