# how to divide two numbers in c# [Resolved]

Posted by Tarawatruchika under C# on 5/12/2012 | Points: 10 | Views : 9560 | Status : [Member] | Replies : 7
i want to divide two numbers and then multiply 20 in result value.

my code is:
mm = Convert.ToInt32(ds.Tables[0].Rows[0][1].ToString());
a = (TextBox)row.FindControl("T1");
m = (float)(Convert.ToInt32(a.Text) / mm) * 20;

for example:
a=20, mm=40
so m should be (20/40)*20=10.

but in programming, divide ("/") give 0 when we try 20/40 instead of 0.5. so i always get value of m is 0 except a=40.
how can i do this? i want m=10, not 0.

#### Responses

Posted by: Moaa Memo on: 5/12/2012 [Member] Starter | Points: 50
 0 hi in windows form app drag 3 text box and one bottm in butom click event write this code double m = Convert.ToDouble(textBox1.Text); double j = Convert.ToDouble(textBox2.Text); double r = Convert.ToDouble((m / j) * 20); textBox3.Text = r.ToString(); Tarawatruchika, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Sakthi.Singaravel on: 5/12/2012 [Member] Silver | Points: 25