首页 > 电脑

怎么解决:控制离开当前方法之前必须对out参数“choice”赋值?

更新时间2021-05-09 01:03:31

private TextBox selected_box(out int choice)
        {
            TextBox selected = null;
 
            if (radioButton1.Checked)
            { selected = textBox1; choice = 1; }
            else if (radioButton2.Checked)
            { selected = textBox2; choice = 2; }
            else if (radioButton3.Checked)
            { selected = textBox3; choice = 3; }
 
            return selected;
        }
图片上传失败,return下有红线,系统提示控制离开当前方法之前必须对 out 参数“choice”赋值 ?

条件语句 没有列举出所有的况。

要么 在 if 前给一个一个默认值,要么加上 else 分支

相关标签:控制

上一篇:c#编写一个控制台程序,在Main方法中用户依次从小到大输入两个整数,

下一篇:二分查找C++的问题