That depends. Can you spare some time when these byte arrays are initialy
loaded or created to compute hash values? If so, do that and compare the
hashes. If not, a simple loop comparing each byte and returning false on
the first mismatch will probably be your best bet.
However, look for ways to optimize this based on your data: if the array is
normally modified at the end only, start comparing at the end. If certain
offsets are more likely to be different, compare those. If your code is the
one modifying the byte array, and the arrays are changed infrequently, use
hashes and check them on subsequent tries.
As you can see, there's no one most efficient method, if you really want to
perform best you need to know your data and how it's modified.
José Joye said:
I have to compare 2 byte[] and I must be sure that they are fully identic.
I have to perform this check about 1000 times per minute and on arrays that
are between 100-200K in size.
In that sense, what is the most efficient method?
Sincerely,
José