更新时间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 分支