nbohana wrote:[color=blue]
> I have tried several methods in converting my string data to an int. I am
> getting a message back 'Input string was not in a correct format'[/color]
<snip>[color=blue]
> cost1 = int.Parse(lcost);
>
> where cost1 is defined as a int, and lcost is a string. the data in lcost =
> "35.00".
>
> How do I fix this problem, I need help??
>[/color]
"35.00" is not an integer, it's a floating point value. Arguably you
could say it's an integer because the part after the decimal point is
".00", but it's still formatted as a floating point value so Int32.Parse
will definitely not like it.
If you know it's always ".00", you could either:
- remove ".00" by using .Replace(".00", ""), before running it through
Int32.Parse
- use Double.Parse, and Convert.ToInt32 afterwards
--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:lasse@vkarlsen.no
PGP KeyID: 0x2A42A1C2