为什么 Exists 函数使用 == 和 != 的结果不是相反的?

Why the result of Exists function use == and != is not opposite?

string input = "1234";
string[] array = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

bool in_N1 = Array.Exists(array, x => x == input.Substring(0, 1));
bool in_N2 = Array.Exists(array, x => x == input.Substring(1, 1));
bool in_N3 = Array.Exists(array, x => x == input.Substring(2, 1));
bool in_N4 = Array.Exists(array, x => x == input.Substring(3, 1));

Console.WriteLine(input.Substring(0, 1) + in_N1);
Console.WriteLine(input.Substring(1, 1) + in_N2);
Console.WriteLine(input.Substring(2, 1) + in_N3);
Console.WriteLine(input.Substring(3, 1) + in_N4);

bool in_N5 = Array.Exists(array, x => x != input.Substring(0, 1));
bool in_N6 = Array.Exists(array, x => x != input.Substring(1, 1));
bool in_N7 = Array.Exists(array, x => x != input.Substring(2, 1));
bool in_N8 = Array.Exists(array, x => x != input.Substring(3, 1));

Console.WriteLine(input.Substring(0, 1) + in_N5);
Console.WriteLine(input.Substring(1, 1) + in_N6);
Console.WriteLine(input.Substring(2, 1) + in_N7);
Console.WriteLine(input.Substring(3, 1) + in_N8);

//the result I got
1True
2True
3True
4True
1True
2True
3True
4True

ps.I 也试过用 "+" 或 + "-" 之类的符号输入,布尔结果和我想的一样。但是如果我输入数字就有问题,我很困惑...

让我们做一个high-level你要求 C# 评估的英文版本..

a) Dear C#, here are some numbers: 1,2,3,4. Does there exist any number in that set that is EQUAL to 1?

b) Dear C#, here are some numbers: 1,2,3,4. Does there exist any number in that set that is NOT EQUAL to 1?


在第一种情况下,C# 说是,因为 1 等于 1。在第二种情况下,C# 说是,因为 2 不等于 1