error when converting string decimal to integer

M

mdawoodk

i am getting error "input string was not in correct format" when
converting a string decimal into integer value.

code is like this:

string strVal = "";
int nVal = 0;

strVal = "14.9";
nVal += Convert.toInt32(strVal);

Above code is a function which is in a dll and its return type is int.
So i cant just change the convertion to decimal as this function is
being used in other projects. Any body has some clue or suggestion
which is appreciated.
 
N

Nick Hounsome

i am getting error "input string was not in correct format" when
converting a string decimal into integer value.

code is like this:

string strVal = "";
int nVal = 0;

strVal = "14.9";
nVal += Convert.toInt32(strVal);

Above code is a function which is in a dll and its return type is int.
So i cant just change the convertion to decimal as this function is
being used in other projects. Any body has some clue or suggestion
which is appreciated.

convert the string to decimal and then cast the decimal to int.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top