I have the following code:
List<byte[]> list1 = new List<byte[]>();
list1.Add(new byte[] { 0x41, 0x41, 0x41, 0x41, 0x78, 0x56, 0x34, 0x12 });
List<byte[]> list2 = new List<byte[]>();
list2.Add(new byte[] { 0x41, 0x41, 0x41, 0x41, 0x78, 0x56, 0x34, 0x12 });
list2.Add(new byte[] { 0x42, 0x42, 0x42, 0x42, 0x78, 0x56, 0x34, 0x12 }); // this array
IEnumerable<byte[]> list3 = list2.Except(list1);
我希望 list3 只包含在 list2 中但不在 list1 中(标为“this array”的数组)的byte[] 数组,但它只返回 list2 中的所有内容。然后我尝试了以下方法:
List<byte[]> list3 = new List<byte[]>();
foreach (byte[] array in list2)
if (!list1.Contains(array))
list3.Add(array);
但这样做我得到了相同的结果。我错在哪里了?