Easiest way to compare arrays in C#
问题 In Java, Arrays.equals() allows to easily compare the content of two basic arrays (overloads are available for all the basic types). Is there such a thing in C#? Is there any \"magic\" way of comparing the content of two arrays in C#? 回答1: You could use SequenceEqual. This works for any IEnumerable<T> , not just arrays. 回答2: Use SequenceEqual in LINQ. int[] arr1 = new int[] { 1,2,3}; int[] arr2 = new int[] { 3,2,1 }; Console.WriteLine(arr1.SequenceEqual(arr2)); // false Console.WriteLine(arr1