0
我有3名名单和类别:使用LINQ正确的测验,并按照主题
List<student_Answers> student_answer = new List<student_Answers>
{new student_Answers {id = "1", q1 ="*C", q2= "*D", q3 = "*B", q4= "*A" },
new student_Answers {id = "2", q1 ="*D", q2= "*E", q3 = "*B", q4= "*A" }};
List<answer> correct_answer = new List<answer>
{new answer{r1 ="*C", r2= "*D", r3 = "*B", r4= "*C" }};
List<Topic> topic_question = new List<Topic>
{ new Topic{ q1_topic ="Verb to be", q2_topic= "Verb to be", q3_topic = "Listening", q4_topic= "Listening" }};
我想:
foreach (var na in student_answer)
{var grade = from n in student_answer where !na.Contains(n) select n;}
它不工作,我不知道该怎么组我的问题在主题。
预期输出:
失败问题:
Id= 1 : Failed in question = 4 : Topic = "Listening" Id= 2 : Failed in question = 1 : Topic = "Verb to be" Id= 2 : Failed in question = 4 : Topic = "Listening"
主题百分比:
Listening = 2/4 = 50% incorrect Verb to be = 1/4 = 25% incorrect
为什么要为'q1','q2'和'r1','r2'存储不同的属性?列表或数组不会更有意义吗?否则,我认为你必须通过反射来访问你的命名属性。 – Rup 2013-02-11 15:22:07