본문 바로가기

C#/String | Byte | Int

C# Byte Array Compare 바이트 비교

C# Byte Array Compare 바이트 비교

 

 

[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int memcmp(byte[] b1, byte[] b2, long count);
static bool ByteArrayCompare(byte[] b1, byte[] b2)
{
    if (b1 == null || b2 == null)
    {
        return false;
    }
    // Validate buffers are the same length.
    // This also ensures that the count does not exceed the length of either buffer. 
    return b1.Length == b2.Length && memcmp(b1, b2, b1.Length) == 0;
} 

'C# > String | Byte | Int' 카테고리의 다른 글

C# byte 압축 / 해제  (0) 2020.07.29
C# Byte Array에 Byte Array 합치기  (0) 2020.07.27
C# 난수 생성  (0) 2020.07.26