how to solve attempted to divide by zero in c#?

c#, decimal, division, textbox

Solution

How about simply using an `if` to check before dividing by zero?

if(tnure != 0)
    txtDdctAmnt.Text = (Amnt / tnure).ToString("0.00");
else
    txtDdctAmnt.Text = "Invalid value";

Problem

I am getting this bug, I wrote code like this 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 I am getting this error.If it is possible give answer to me.

Original source