小编use*_*857的帖子

Except()为两个数组提供了错误的输出?

我有两个数组,我需要显示array1没有的数组,反之亦然.

string[] a = { "hello", "momo" }
string[] b = { "hello"}
Run Code Online (Sandbox Code Playgroud)

输出:

momo
Run Code Online (Sandbox Code Playgroud)

我正在使用.Except并尝试在消息框中显示输出,但是当我执行我的代码时,输​​出是这样的:

System.Linq.Enumerable+<ExceptIterator>d_99'1[System.Char]
Run Code Online (Sandbox Code Playgroud)

我的代码:

//Array holding answers to test
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 = Convert.ToString(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 …
Run Code Online (Sandbox Code Playgroud)

.net c# linq except

0
推荐指数
1
解决办法
678
查看次数

标签 统计

.net ×1

c# ×1

except ×1

linq ×1