我有六个单选框,text属性分别是:A,B,C,D,E,F,如何将其传递给switch语句的表达式啊~~~
switch (radius)
{ case A:
atmosphereStability = 1; //此时的atmosphereStability的值1、2、3、4、5、6对应大气稳定度等级A、B、C、D、E、F
case B:
atmosphereStability = 2;
case C:
atmosphereStability = 3;
case D:
atmosphereStability = 4;
case E:
atmosphereStability = 5;
case F:
atmosphereStability = 6;
} private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
RadioButton radioButton2 = new RadioButton();
string radius = Convert.ToString(radioButton2.Text); //将radioButton的Text值赋给radius变量
}
switch (radius)
{ case A:
atmosphereStability = 1; //此时的atmosphereStability的值1、2、3、4、5、6对应大气稳定度等级A、B、C、D、E、F
case B:
atmosphereStability = 2;
case C:
atmosphereStability = 3;
case D:
atmosphereStability = 4;
case E:
atmosphereStability = 5;
case F:
atmosphereStability = 6;
} private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
RadioButton radioButton2 = new RadioButton();
string radius = Convert.ToString(radioButton2.Text); //将radioButton的Text值赋给radius变量
}
解决方案 »
- [原创视频教程]C#水晶报表一看就会了视频教程
- 如何在C#写的WINDOWS服务中,使线程在固定的时间运行?
- 求教一个关于ADO.NET Datacolumn的问题
- 在添加关闭提示时barmanager出现的问题
- 那位能发一个Windows ce 上 sqlce 操作的例子
- 问下大家有没有做过XMPP协议中的文件传输的服务器端的代码啊!!!
- 问一个想不明白的问题,大神们请给个解答,万分感谢.
- 如何用C#在本地建立mdb文件并操作它
- c#请教 怎样才能让角色移动到鼠标的位置而不是闪过去
- TextWriter可否转型为Stream?
- 如何实现word中垂直文本框的控件
- 有谁介绍一本有关Winform自定义控件的书?
atmosphereStability = 1;
if (...)
...
for(int i=0;i<radios.Length;i++)
{
if(radios[i].Checked)
{
atmosphereStability = i;
break;
}
}
{
if (c.GetType() == typeof(RadioButton)
if (RadioButton)c.Value = 1) {
atmosphereStability = (int)((char)c.Text) - 64;
break;
}
}无聊。
atmosphereStability =radius[0]-'A'+1;
另外,这里:string radius = radioButton2.Text; //将radioButton的Text值赋给radius变量string赋给string类型的变量无须Convert。