c# radiobutton 选择输出问题

.Net技术 码拜 8年前 (2016-03-07) 1366次浏览
 private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            int a = 1, b = 2;
            int c;
            if (radioButton1.Checked == true)
            {
                c = a + b;
                radioButton2.Checked = false; 
            }
            if (radioButton2.Checked == true)
            {
                c = a - b;
                radioButton2.Checked = false;
            }
        }

判断是摁下了radiobutton1还是radiobutton2,然后点击按钮输出c,该怎么写呢

解决方案

30

引用 2 楼 baidu_34817953 的回复:

恩,那在button事件中该怎么写呢?是调用radiobutton码?

你要么把c改全局变量,要么直接写button的click事件里


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明c# radiobutton 选择输出问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)