Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#在运行时向交换机添加更多案例_C#_Switch Statement_Runtime_Add - Fatal编程技术网

c#在运行时向交换机添加更多案例

c#在运行时向交换机添加更多案例,c#,switch-statement,runtime,add,C#,Switch Statement,Runtime,Add,我做了一个有多项选择题的测试程序。我想做一个新的部分,“老师”可以在测试中添加更多的问题。多项选择是通过开关箱实现的 switch (qstNumber) { case 1: txtQuestion.Text = "sdfgsdf"; // question rdoAnswer1.Text = "A"; // possible answers

我做了一个有多项选择题的测试程序。我想做一个新的部分,“老师”可以在测试中添加更多的问题。多项选择是通过开关箱实现的

switch (qstNumber)
        {

            case 1: 
                txtQuestion.Text = "sdfgsdf"; // question



                rdoAnswer1.Text = "A";         // possible answers
                rdoAnswer2.Text = "B";
                rdoAnswer3.Text = "Γ ";
                rdoAnswer4.Text = "Δ";
                break;

所以我想添加一个新的文本框,并将文本复制到一个新的开关中。我该怎么做?

您不想在运行时添加开关;你根本不想使用开关。您想定义一个类,其中类的对象是测试中的问题。然后,您将拥有该类的对象列表,即测试;您可以在运行时添加或删除此列表中的项