首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

这个句子有啥有关问题呀

2012-01-05 
这个句子有啥问题呀protectedvoidButton1_Click(objectsender,EventArgse){if(RadioButton1.Text )Re

这个句子有啥问题呀
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的值不为数字的话,就会包错,所以最好加个判断

热点排行