this is my code;
string a="11.4";
int b,c;
b=2;
c= convert.toint32(a) * b
I get this error;
Input string was not in a correct format
how can i convert “a”?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well
ais just not an integer value – you could useConvert.ToDouble()instead. To guard against parsing errors in case that is a possibility usedouble.TryParse()instead:Edit:
Taking the comments into account, of course it is always best to specify the culture settings. Here an example using culture-indepenent settings with
double.TryParse()which would result in11.4as result: