1

Well what i need to do is compare two byte arrays byte by byte and return there difference in int so then I'll use them in a progress bar.

But I don't have a single idea how could i do this. just give me a pseudo code. or some sort of explanation It will be helpful for me

4
  • each array should represent an integer value ? Not sure to understand. Commented Jan 24, 2016 at 9:33
  • 2
    difference... ? what do you mean by difference? like 50-20 30 is the difference... if it's byte by byte difference then how can it be returned by an int? Commented Jan 24, 2016 at 9:33
  • Difference could be like in byte1 first byte matches the byte2 first byte. then it will make count 1 and so on. At the end for the sake of argument count will be like 20-30 so the difference between both of these arrays are 20-30 Commented Jan 24, 2016 at 9:37
  • oh.. and will the array lengths be same all the time? Commented Jan 24, 2016 at 9:41

1 Answer 1

4

If you just want a count of the number of differences try this

            byte[] array1 = new byte[2];
            byte[] array2 = new byte[2];

            int diff = array1.Where((x, i) => x != array2[i]).Count();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.