Compare two array with offset - CSharp System

CSharp examples for System:Array Compare

Description

Compare two array with offset

Demo Code



public class Main{
        public static int Compare(this byte[] arry, int offset, byte[] other, int otherOffset, int len)
        {/*from   ww  w.  ja v  a 2s.  c  om*/
            int ret = 0;
            for (int i = len - 1; i >= 0 && ret == 0; i--)
            {
                ret = arry[i + offset] - other[i + otherOffset];
            }
            return ret;
        }
        public static int Compare(this byte[]arry, byte[] other)
        {
            int ret = 0;
            for(int i =arry.Length-1; i >=0 && ret == 0; i--)
            {
                ret = arry[i] - other[i];
            }
            return ret;
        }
}

Related Tutorials