c# - asp.net decimal multiplication -


I have a problem, my multiplication will work perfectly with the whole number, but when I use decimal numbers I try to do so it cries and throws anger of anger is an error log here:

The input string was not in a correct format.

Description: An uncontrolled exception occurred during the execution of the current Web request. Please review the stack trace for more information about the error and where the code originated from it.

Exception Description: System.FormatException: The input string was not in a correct format.

Source Error:

  Line 15: Protected Zero Button 1_Click (Object Sender, EventsErggs) Line 16: {Line 17: Int P = Convert. ToInt32 (Hourly Forward text); Line 18: Int q = Convert. ToInt32 (Hourspeed Lesson); Line 19: int t = p * q;  

This is also the real method of multiplication by me, any help would be appreciated

If you are entering a decimal number, then you should use that code instead of int . convert toDecimal , use decimal. Purse or safe option to get as number:

  decimal hour; If (decimal. Terriers (hourly futures, text, hourly wow)) {// valid decimal number} other {// invalid input}  

hourPerWeek And then store the result of multiplication in a decimal type variable


Comments