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

Posted by Tarawatruchika under C# on 5/12/2012 | Points: 10 | Views : 12368 | Status : [Member] | Replies : 6
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: Hariinakoti on: 5/12/2012 [Member] Starter | Points: 25
 0 Hi, float m=convet.ToFloat(textbox1.Text); float n=convert.ToFloat(textbox2.Text); float res=convert.ToFloat((m/n)*20); textbox3.Text=res.ToString();Thanks & Regards HariTarawatruchika, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Tarawatruchika on: 5/12/2012 [Member] Starter | Points: 25
 0 convert.ToFloat is not any method. i got my solution with "double"Tarawatruchika, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Tarawatruchika on: 5/12/2012 [Member] Starter | Points: 25