(请教高手)计算器进制转换???
private void radioButton4_CheckedChanged(object sender, EventArgs e) //二进制radiobutton{
if (this.radioButton4.Checked)
{
convertstring(4);
}
}
private void radioButton3_CheckedChanged(object sender, EventArgs e) //八进制radiobutton
{
if (this.radioButton3.Checked)
{
convertstring(3);
}
}
private void radioButton2_CheckedChanged(object sender, EventArgs e) //十进制radiobutton
{
if (this.radioButton2.Checked)
{
convertstring(2);
}
}
private void radioButton1_CheckedChanged(object sender, EventArgs e) //十六进制radiobutton
{
if (this.radioButton1.Checked)
{
convertstring(1);
}
}
public void convertstring(int th)
{
switch (th)
{
case 1:
intvalue = Convert.ToInt32(txtResult.Text, frombase);
value = Convert.ToString(intvalue, 16);
txtResult.Text = value.ToString();
frombase = 16;
break;
case 2:
intvalue = Convert.ToInt32(txtResult.Text, frombase);
value = Convert.ToString(intvalue, 10);
txtResult.Text = value.ToString();
frombase = 10;
break;
case 3:
intvalue = Convert.ToInt32(txtResult.Text, frombase);
value = Convert.ToString(intvalue, 8);
txtResult.Text = value.ToString();
frombase = 8;
break;
case 4:
intvalue = Convert.ToInt32(txtResult.Text, frombase);
value = Convert.ToString(intvalue, 2);
txtResult.Text = value.ToString();
frombase = 2;
break;
}
}
为什么运行后没有作用????