Interesting use of TryParse
-
double.TryParse(Amount, out dAmount); if (dAmount == double.MinValue) throw new ApplicationException("Item amount cannot be converted to a number.");
-
Maybe it's just someone who's used to VB.NET's TryCast.
-
Heh. I like this one. It reminds me of something I would have done when I started programming.
-
Original: @campkev said:
Proper:double.TryParse(Amount, out dAmount);
if (dAmount == double.MinValue)
throw new ApplicationException("Item amount cannot be converted to a number.");
Correct:if(!Double.TryParse(Amount, out dAmount))
throw new ApplicationException("Item amount cannot be converted to a number.");dAmount = Double.Parse(Amount);