β System.FormatException
Me and another are writing a RPN calculator.
I get this error message when trying to calculate
3 4.8 5.7 + * 2.5 *
but when he runs it he does not get an exception on it. We have the exact same files and code. Why?4 Replies
Your PC is probably set to a language that uses a comma as a decimal separator, not a period
Try inputting the same string, but with commas
Also, I recommend using
TryParse()
instead of the Convert
class, it lets you check if a number is valid without throwing exceptions
If you want to continue using periods for separators, you can set the culture of the thread to InvatiantCulture
, or pass CultureInfo.InvariantCulture
as a second parameter to your convert method
Or to TryParse()
Could this issue be resolved by using
Double
instead?No
Thanks king! works now :catHeyHello: