c#比较两个字节数组是否一样

/// <summary>
        /// 比较两个字节数组是否一样
        /// </summary>
        /// <param name="b1"></param>
        /// <param name="b2"></param>
        /// <returns></returns>
        public static bool ByteArraysEqual(byte[] b1, byte[] b2)
        {
            if (b1 == b2) return true;
            if (b1 == null || b2 == null) return false;
            if (b1.Length != b2.Length) return false;
            for (int i = 0; i < b1.Length; i++)
            {
                if (b1[i] != b2[i]) return false;
            }
            return true;
        }

 

posted @ 2023-06-07 17:58  tommy~hi  阅读(71)  评论(0编辑  收藏  举报