Code :
int TopAttuale = Int32.Parse("1579.998779296875");
it says
System.FormatException: Input string was not in a correct format.
But that’s what I have. How can I convert that string into INT (so 1579, I don’t care about the comma)?
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.
It sounds like you should parse it as a
decimalfirst, then just cast toint. (I’d usedecimalrather thandoubleas you’ve really got decimal input;decimalwill represent your source data more accurately. It shouldn’t make any difference though, by the time you cast it.)Alternatively, see if there’s a decimal point, and if so trim everything after it, then parse the result.