Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to avoid the error and get 0 for empty value
Message
 
 
To
All
General information
Forum:
C#
Category:
Coding, syntax and commands
Title:
Best way to avoid the error and get 0 for empty value
Miscellaneous
Thread ID:
01654373
Message ID:
01654373
Views:
45
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
Next
Reply
Map
View

Click here to load this message in the networking platform