먼저, 비교할 두 배열을 설정하십시오 -
// 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));
}
}
}