Compare arrays

  • Thread starter Thread starter Jacob Thastrup
  • Start date Start date
J

Jacob Thastrup

Hi is there an easy way to compare arrays without going through each
entry in the arrays?
Say I have two arrays and I want to find entries that are not present in
both.

Thanks

Jacob Thastrup
 
public static bool CompareByteArrays (byte[] data1, byte[] data2)
{
// If both are null, they're equal
if (data1==null && data2==null)
{
return true;
}
// If either but not both are null, they're not equal
if (data1==null || data2==null)
{
return false;
}
if (data1.Length != data2.Length)
{
return false;
}
for (int i=0; i < data1.Length; i++)
{
if (data1 != data2)
{
return false;
}
}
return true;
}
 
Back
Top