C#中如何比较二进制数组
两种方法,一是自己实现
private bool SameBytes(byte[] ABuffer1, byte[] ABuffer2)
{
if (ABuffer1.Length != ABuffer2.Length) return false;
for (int i = 0; i < ABuffer1.Length; i++)
if (ABuffer1[i] != ABuffer2[i]) return false;
return true;
}
一个是调系统API:
C# codeusing System.Runtime.InteropServices;
[DllImport("ntdll.dll")]
public static extern int RtlCompareMemory(IntPtr Destination,
IntPtr Source, int Length);
请参考: