Quantcast
Viewing latest article 2
Browse Latest Browse All 5

Answer by Tim Schmelter for Compare 2 byte arrays

Here is another (less readable but maybe a little bit more efficient) approach that does not need LINQ:

public static int[] GetDifference(int[] first, int[] second){    int commonLength = Math.Min(first.Length, second.Length);    int[] diff = new int[commonLength];    for (int i = 0; i < commonLength; i++)        diff[i] = Math.Abs(first[i] - second[i]);    return diff;}

Why little bit more efficient? Because ToArrayhas to resize the array until it knows the final size.


Viewing latest article 2
Browse Latest Browse All 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>