int numVal = Convert.ToInt32("-105");
Error
Input string was not in a correct format.
Please suggest me any alternative to give <0 value in int
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Surya KantRank #958 · 2.1K reputationPosted Jan 30, 2020, 2:08 AM EST
Ashutosh GuptaRank #805 · 2.9K reputationPosted Jan 30, 2020, 5:14 AM EST
Convert.ToInt32() converts the string data to a proper true int32 value, and throws an exception if it can't convert the value.