Answer the question
In order to leave comments, you need to log in
How to solve error when converting string to real number?
You need to move the number behind a comma, did the conversion to double
and gives an error: 'Input string was not in a correct format.'
Although there is an English version of visual studio, it should count a dot, not a comma.
Maybe overlooked something
string stri = "0." + artQuantity;
double probability = Convert.ToDouble(stri);
Answer the question
In order to leave comments, you need to log in
1. It does not depend on the studio, but on the system locale.
2. When parsing, it is better to always explicitly specify the locale used.
In your case, this would work:
var str = "0." + artQuantity;
var probability = double.Parse(str, System.Globalization.CultureInfo.InvariantCulture);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question