CSharp examples for System:Byte Array
Byte to byte array comparing via LINQ.
using System.Linq; using System;//from w w w. ja v a 2s. c o m public class Main{ /// <summary> /// Byte to byte array comparing. /// </summary> /// <param name="bytes1"></param> /// <param name="bytes2"></param> /// <returns></returns> public static bool EqualsTo(this byte[] bytes1, byte[] bytes2) { if (bytes1 == null) throw new ArgumentNullException("bytes1"); if (bytes2 == null) throw new ArgumentNullException("bytes2"); if (ReferenceEquals(bytes1, bytes2)) return true; if (bytes1.Length != bytes2.Length) return false; return !bytes1.Where((t, i) => t != bytes2[i]).Any(); } }