A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
620 B

#nullable enable
using System;
using System.Collections.Generic;
public sealed class ByteArrayEqualityComparer : IEqualityComparer<byte[]>
{
public static ByteArrayEqualityComparer Instance { get; } = new();
public bool Equals(byte[]? x, byte[]? y) {
if (ReferenceEquals(x, y))
return true;
if (x is null || y is null)
return false;
return x.AsSpan().SequenceEqual(y.AsSpan());
}
public int GetHashCode(byte[]? obj)
{
var hashCode = new HashCode();
hashCode.AddBytes(obj.AsSpan());
return hashCode.ToHashCode();
}
}