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();这个句子不对那?错在那里呀

解决方案 »

  1.   

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

  2.   

    rr = ((float.Parse(TextBox1.Text)  - 32)*5/9);  在TextBox1为空的时候会出异常,建议声明的时候初始化;
      

  3.   

    这样测试是可以的
    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的值不为数字的话,就会包错,所以最好加个判断