C#中如何比较两个数组?

C#中如何比较两个数组?

首先,设置要比较的两个数组 -

// two arrays int[] arr = new int[] { 99, 87, 56, 45}; int[] brr = new int[] { 99, 87, 56, 45 };登录后复制

arr.SequenceEqual(brr);登录后复制

示例

using System; using System.Linq; namespace Demo { class Program { static void Main(string[] args) { // two arrays int[] arr = new int[] { 99, 87, 56, 45}; int[] brr = new int[] { 99, 87, 56, 45 }; // compare Console.WriteLine(arr.SequenceEqual(brr)); } } }登录后复制