读书人

关于switch的有关问题

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

关于switch的问题

C# code
 if (this.radioButton2.Checked)            {                this.skinEngine1.SkinFile = "EmeraldColor2.ssk";                return;            }            else if (this.radioButton3.Checked)            {                this.skinEngine1.SkinFile = "MidsummerColor2.ssk";                return;            }            

请问下 如果要转成 switch的话怎么写。 radiobutton 没有 selectvalue属性啊。。

[解决办法]
你是判断它是不是被选中...
用switch的话不如直接用if else呢

foreach (RadioButton rad in this.Controls)
{
switch (rad.Name)
{
case "radioButton2":
if (radioButton2.Checked)
{ this.skinEngine1.SkinFile = "EmeraldColor2.ssk";
}
break;
case "radioButton3":

}
}

读书人网 >C#

热点推荐