Example #1
0
 /// <summary>
 /// Compares two byte or byte array values.
 /// </summary>
 public static bool EqualBytes(byte[] a, byte[] b)
 {
     if (a == null)
     {
         return(b == null);
     }
     if (b == null)
     {
         return(a == null);
     }
     if (a is Array && b is Array)
     {
         int pos = 0;
         if (((Array)a).Length != ((Array)b).Length)
         {
             return(false);
         }
         foreach (byte mIt in (byte[])a)
         {
             if ((((byte)((byte[])b).GetValue(pos++)) & mIt) != mIt)
             {
                 return(false);
             }
         }
     }
     else
     {
         return(BitConverter.Equals(a, b));
     }
     return(true);
 }