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