Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# e OP说“北==”北,南“?不知道为什么。@SriramSakthivel,因为“北,南”包含“北”。同样地,“南,北”==”北,东”出于同样的原因,但不能使用“包含”“为了测试这种等价性。@SamJolly那么如果其中任何一个匹配,你需要返回true吗_C#_C# 4.0_C# 5.0 - Fatal编程技术网

C# e OP说“北==”北,南“?不知道为什么。@SriramSakthivel,因为“北,南”包含“北”。同样地,“南,北”==”北,东”出于同样的原因,但不能使用“包含”“为了测试这种等价性。@SamJolly那么如果其中任何一个匹配,你需要返回true吗

C# e OP说“北==”北,南“?不知道为什么。@SriramSakthivel,因为“北,南”包含“北”。同样地,“南,北”==”北,东”出于同样的原因,但不能使用“包含”“为了测试这种等价性。@SamJolly那么如果其中任何一个匹配,你需要返回true吗,c#,c#-4.0,c#-5.0,C#,C# 4.0,C# 5.0,e OP说“北==”北,南“?不知道为什么。@SriramSakthivel,因为“北,南”包含“北”。同样地,“南,北”==”北,东”出于同样的原因,但不能使用“包含”“为了测试这种等价性。@SamJolly那么如果其中任何一个匹配,你需要返回true吗?@SriramSakthivel:我想这只是意味着一个字符串北也与北,南相交。这就是String.Split的工作原理。即使是单个字符串也会使用该字符串创建一个string[]。这很有趣,因为该值是通过LINQ从DB中生成的。这很有趣,因为该


e OP说“北==”北,南“?不知道为什么。@SriramSakthivel,因为“北,南”包含“北”。同样地,“南,北”==”北,东”出于同样的原因,但不能使用“包含”“为了测试这种等价性。@SamJolly那么如果其中任何一个匹配,你需要返回true吗?@SriramSakthivel:我想这只是意味着一个字符串
也与
北,南
相交。这就是
String.Split
的工作原理。即使是单个字符串也会使用该字符串创建一个
string[]
。这很有趣,因为该值是通过LINQ从DB中生成的。这很有趣,因为该值是通过LINQ从DB中生成的。这很有趣,因为该值是通过LINQ从DB中生成的。
"North, South, East" == "North, East, South" 
both contain "North"
both contain "South"
"North" == "North, South"
"North" != "South"
"North, South" == "South, North"
var tokens1 = "North, South, East".Split(',').Select(s => s.Trim());
var tokens2 = "North, East, South".Split(',').Select(s => s.Trim());
bool anyIntersection = tokens1.Intersect(tokens2).Any();
string NEWS = "North, South, East";
string NEW = "North, East, South";

var temp1 = NEWS.Split(',');
var temp2 = NEW.Split(',');

if (temp1.Any(x => temp2.Contains(x)))
{
 // means equal
}
string s1 = "North, South, East";
string s2 = "East, West, South";

var strings1 = s1.Split(',').Select(s => s.Trim());
var strings2 = s2.Split(',').Select(s => s.Trim());

var stringsInCommon = strings1.Intersect(strings2);

Console.WriteLine("Strings in common: " + string.Join(", ", stringsInCommon));