convenience function to check if the content of array1 matches array2

This commit is contained in:
Michael Becker 2020-09-25 18:14:33 -04:00
parent 72ab8dddd3
commit a8bf093b92
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7

View File

@ -54,5 +54,18 @@ namespace MBS.Framework
Array.Resize<T>(ref destinationArray, destinationArray.Length + sourceArray.Length); Array.Resize<T>(ref destinationArray, destinationArray.Length + sourceArray.Length);
Array.Copy(sourceArray, 0, destinationArray, start, sourceArray.Length); Array.Copy(sourceArray, 0, destinationArray, start, sourceArray.Length);
} }
public static bool Matches<T>(this T[] array1, T[] array2)
{
if (array1.Length != array2.Length)
return false;
for (int i = 0; i < array1.Length; i++)
{
if (!array1[i].Equals(array2[i]))
return false;
}
return true;
}
} }
} }