读书人

这个句子有啥有关问题呀

发布时间: 2012-01-05 22:36:54 作者: rapoo

这个句子有啥问题呀
protected void Button1_Click(object sender, EventArgs e)
{

if (RadioButton1.Text == " ")
Response.Write( "初始值不能为空 ");
else
{
float rr;
if (RadioButton1.Checked==true)

rr = ((float.Parse(TextBox1.Text) - 32)*5/9);
TextBox2.Text = rr.ToString();
}


}
//TextBox2.Text = rr.ToString();这个句子不对那?错在那里呀

[解决办法]
将 rr = ((float.Parse(TextBox1.Text) - 32)*5/9);
TextBox2.Text = rr.ToString();
加个{}
{
rr = ((float.Parse(TextBox1.Text) - 32)*5/9);
TextBox2.Text = rr.ToString();
}
[解决办法]
同意上面两位,一加括号,二赋初值
[解决办法]
其它的好像没什么错了啊!!!

[解决办法]
这样测试是可以的
if(this.radioButton1.Text==null)
{
MessageBox.Show( "初始化失败 ");
}
else
{
float rr;
if(this.radioButton1.Checked==true)
{
rr=((float.Parse(this.textBox3.Text)-32)*5/9);
this.textBox4.Text =rr.ToString();
}
}
但是如果TextBox1的值不为数字的话,就会包错,所以最好加个判断

读书人网 >C#

热点推荐