Comparing Arrays using LINQ in C#

前端 未结 6 948
闹比i
闹比i 2020-12-15 04:46

I\'ve two arrays like

string[] a = { \"a\", \"b\", \"c\" };
string[] b = { \"a\", \"b\", \"c\" };

I need to compare the two arrays using LI

6条回答
  •  我在风中等你
    2020-12-15 05:49

    This works correctly with duplicates and check each element

    a.Length == b.Length && !a.Where((t, i) => t != b[i]).Any()
    

提交回复
热议问题