I have a dictionary as follows
Dictionary<ulong, Dictionary<byte[], byte[]>> Info;
And the inner dictionary holds a byte[] array as a key.
I am unable to understand how to declare the constructor for a the Info
dictionary. For the inner key comparison I have ByteArrayComparer
,
public class ByteArrayComparer : IEqualityComparer<byte[]>
{
public bool Equals(byte[] left, byte[] right)
{
if (left == null || right == null)
{
return left == right;
}
if (left.Length != right.Length)
{
return false;
}
for (int i = 0; i < left.Length; i++)
{
if (left[i] != right[i])
{
return false;
}
}
return true;
}
public int GetHashCode(byte[] key)
{
if (key == null)
throw new ArgumentNullException("key");
int sum = 0;
foreach (byte cur in key)
{
sum += cur;
}
return sum;
}
}
Which I picked up from SO Here
Please advise