All Byte Array Are Equal - CSharp System

CSharp examples for System:Byte Array

Description

All Byte Array Are Equal

Demo Code


using System.Linq;
using System;/*  w ww . j a v  a2s  .c o  m*/

public class Main{
        public static bool AllBytesAreEqual(this byte[] array, byte[] otherarray)
        {
            if(array == null)
                throw new ArgumentNullException("array");
            if(otherarray == null)
                throw new ArgumentNullException("otherarray");

            if (array.Length == 0 || otherarray.Length == 0)
                throw new InvalidOperationException();

            if (array.Length != otherarray.Length)
                return false;

            return !array.Where((b, i) => b != otherarray[i]).Any();
        }
}

Related Tutorials