I think the problem is he has a string that contains a % sign so he does not
have the advantage of performing that type of parse.
You may have to look to see if the string contains a % and if it does, strip
it off, parse the value and then devide by 100.
Joe Feser
here is the man of the function public static double Parse(string s);
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcoricsharptutorials.asp
nothing says that the char '%' is authorised in the string s.
the error you have is that you try to parse the char '%'
insteed of this :
double a = Double.Parse("1.25%");
simply use this :
double a = Double.Parse("1.25") / 100;
ROM
"Christian Nein" <
[email protected]> a écrit dans le message de (e-mail address removed)...
Hi,
I am trying to parse percent values (eg. 12.9%) with the
double.parse-function.
double d = double.Parse("12.9%");
Unfortunately, this always throws an exception.
What is the problem?
Regards,
Christian