Quantcast
Viewing all articles
Browse latest Browse all 15

int.Parse oddity

You could report this issue at Product Feedback.  I doubt you'll get anywhere with it though.  You're doing something very unusual; you're saying you want to parse a string in the Currency format but store it into a variable with a type that cannot accurately represent a currency value.  The BCL developers chose to not allow this implicit cast to happen without complaining and that's a Good Thing.  Their problem was however that there isn't a specialization of the System.Exception class that accurately reports what is going wrong.  Dedicating yet another derived exception class for something so unusual would be uncalled for.  Especially because the work-around is trivial:

int value = (int)Decimal.Parse(...);

Viewing all articles
Browse latest Browse all 15

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>