textbox - how to solve attempted to divide by zero in c#? -
i getting bug, wrote code below
code:
decimal amnt; decimal.tryparse(txtamnt.text, out amnt); int tnure=1; int.tryparse(txttnre.text, out tnure); txtddctamnt.text = (amnt /tnure).tostring("0.00");
when in textbox value 0 getting error.if possible give answer me.
how using if
check before dividing zero?
if(tnure != 0) txtddctamnt.text = (amnt / tnure).tostring("0.00"); else txtddctamnt.text = "invalid value";
Comments
Post a Comment