Looking for the most efficient way. I found this on comparing lists regardless of order: https://answers.unity.com/questions/1307074/how-do-i-compare-two-lists-for-equality-not-caring.html
What about comparing array contents regardless of order?
Looking for the most efficient way. I found this on comparing lists regardless of order: https://answers.unity.com/questions/1307074/how-do-i-compare-two-lists-for-equality-not-caring.html
What about comparing array contents regardless of order?
You can use the Intersect
method. Here is a simple console application
using System;
using System.Linq;
class Program
{
static void Main()
{
var nums1 = new int[] { 2, 4, 6, 8, 10, 9 };
var nums2 = new int[] { 1, 3, 6, 9, 12, 2 };
if (nums1.Intersect(nums2).Any()) // check if there is equal items
{
var equalItems = nums1.Intersect(nums2); // get list of equal items (2, 6, 9)
// ...
}
}
}