
首先,设置要比较的两个数组 -
// two arrays
int[] arr = new int[] { 99, 87, 56, 45};
int[] brr = new int[] { 99, 87, 56, 45 };现在,使用 SequenceEqual() 比较两个数组 -
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));
}
}
}










