Home > Article > Backend Development > How to compare two arrays in C#?
First, set up the two arrays to be compared-
// two arrays int[] arr = new int[] { 99, 87, 56, 45}; int[] brr = new int[] { 99, 87, 56, 45 };
Now, use SequenceEqual() to compare the two arrays-
arr.SequenceEqual(brr);
The following is the comparison Code for two arrays -
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)); } } }
The above is the detailed content of How to compare two arrays in C#?. For more information, please follow other related articles on the PHP Chinese website!