[求助]string 如何 转换成float,然后进行算术运算???
ds.Tables[0].Rows[0]["长"].ToString().Trim();ds.Tables[0].Rows[0]["宽"].ToString().Trim();
textbox.text=上面的值相加.
2007-05-30 15:22
2007-05-30 15:30
2007-05-30 15:36

2007-05-30 15:42

2007-05-30 15:59
2007-05-30 16:14
2007-05-30 16:30

2007-05-30 17:00
textBox1.Text = float.Parse(ds.Tables[0].Rows[0]["长"].ToString()) + float.Parse(ds.Tables[0].Rows[0]["宽"].ToString());
错误 1 无法将类型“float”隐式转换为“string”
改一下 更改为:
textBox1.Text = (float.Parse(ds.Tables[0].Rows[0]["长"].ToString()) + float.Parse(ds.Tables[0].Rows[0]["宽"].ToString())).ToString();
这样应该就可以了,float.Parse(ds.Tables[0].Rows[0]["长"].ToString())的结果是float类型的,而textbox1.text要求赋予string类型的值,你没有把相加过的float值转成string类型。

2007-05-30 17:30
[此贴子已经被作者于2007-5-31 9:12:37编辑过]

2007-05-31 08:57