-1
두 개의 배열을 가지고 있습니다. 배열 testAnswer는 "answers to a exam"과 배열 inputAnswers는 "students answers to exam"을 보유하고 있습니다.C#이 함수를 반환하는 intersect 메서드는 무엇입니까?
정확하고 잘못된 대답을 표시하려고합니다. 즉, testAnswer에 inputAnswers가 가지고있는 값 (잘못된 답변)과 두 배열의 값 (정답)을 표시하려고합니다.
linq을 사용하여 .Except 및 .Intersect 메서드를 사용했습니다. 그러나 나는이 이상한 결과를 얻고있다 :
B, D, A, C
누구든지 나를 도울 수있는, 나는이 나이에왔다!
MY CODE :
private void button1_Click(object sender, EventArgs e)
{
string[] testAnswer = new string[20] { "B", "D", "A", "A", "C", "A", "B",
"A", "C", "D", "B", "C", "D", "A", "D", "C", "C", "B", "D", "A" };
string a = String.Join(", ", testAnswer);
// Reads text file line by line. Stores in array, each line of the
// file is an element in the array
string[] inputAnswer = System.IO.File
.ReadAllLines(@"C:\Users\Momo\Desktop\UNI\Software tech\test.txt");
string b = String.Join(", ", inputAnswer);
var inter = inputAnswer.Intersect(testAnswer);
foreach (var s in inter)
{
listBox1.Items.Add(s);
}
}
'inputAnswer'에 테스트 값을 게시 할 수 있습니까? – Habib