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

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -